Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when using logback socket appender #8492

Closed
rotscher opened this issue May 15, 2023 · 0 comments · Fixed by #8498
Closed

Exception when using logback socket appender #8492

rotscher opened this issue May 15, 2023 · 0 comments · Fixed by #8498
Labels
bug Something isn't working

Comments

@rotscher
Copy link

Describe the bug
When using a socket appender with logback then the following exception is thrown:

16:29:16,325 |-INFO in ch.qos.logback.classic.net.SocketAppender[SOCKET] - remote peer localhost:9999: connection failed:  java.io.NotSerializableException: io.opentelemetry.javaagent.shaded.instrumentation.logback.mdc.v1_0.internal.UnionMap
	at java.io.NotSerializableException: io.opentelemetry.javaagent.shaded.instrumentation.logback.mdc.v1_0.internal.UnionMap
	at 	at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1187)
	at 	at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1572)
	at 	at java.base/java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:443)
	at 	at ch.qos.logback.classic.spi.LoggingEventVO.writeObject(LoggingEventVO.java:182)
	at 	at jdk.internal.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
	at 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at 	at java.base/java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1070)
	at 	at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1516)
	at 	at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1438)
	at 	at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1181)
	at 	at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:350)
	at 	at ch.qos.logback.core.net.AutoFlushingObjectWriter.write(AutoFlushingObjectWriter.java:46)
	at 	at ch.qos.logback.core.net.AbstractSocketAppender.dispatchEvents(AbstractSocketAppender.java:236)
	at 	at ch.qos.logback.core.net.AbstractSocketAppender.connectSocketAndDispatchEvents(AbstractSocketAppender.java:194)
	at 	at ch.qos.logback.core.net.AbstractSocketAppender$1.run(AbstractSocketAppender.java:151)
	at 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at 	at java.base/java.lang.Thread.run(Thread.java:833)

Steps to reproduce

Appender in logback.xml

    <appender name="SOCKET" class="ch.qos.logback.classic.net.SocketAppender">
        <remoteHost>localhost</remoteHost>
        <port>9999</port>
        <reconnectionDelay>5000</reconnectionDelay>
        <includeCallerData>false</includeCallerData>
        <queueSize>1024</queueSize>
        <eventDelayLimit>0</eventDelayLimit>
    </appender>

Workaround
Appender works when -Dotel.instrumentation.logback-mdc.enabled=false is set.

What version are you using?

  • opentelemetry-javaagent: 1.25.1
  • logback-classic: 1.4.7

Environment
Compiler: AdoptOpenJDK 17.0.7-1
OS: RedHat 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant