0

Symptom: spring-boot basic app (no web, no jpa, no addons) defines a receiver in logback-spring.xml, but remote appender events never reach the local appenders.

logback-spring.xml:

<configuration debug="true">
    <receiver name="logsink" class="ch.qos.logback.classic.net.server.ServerSocketReceiver">
        <port>6004</port>
    </receiver>

    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss} %-5level %logger{25} - %X{client} %msg %n</pattern>
        </encoder>
    </appender>

    <appender name="crap" class="org.oclc.hadoop.logging.logbacksinksb.service.CrapAppender"/>

    <root level="DEBUG">
        <appender-ref ref="stdout"/>
        <appender-ref ref="crap"/>
    </root>
</configuration>

The crapAppender is stripped to bare-bones for this problem:

public class CrapAppender extends AppenderBase<ILoggingEvent> {
    @Override
    protected void append(ILoggingEvent eventObject) {
        System.out.println("got event!");
    }
}

On startup, the log says my components are being instantiated:

16:39:12,103 |-INFO in ch.qos.logback.classic.joran.action.ReceiverAction - About to instantiate receiver of type [ch.qos.logback.classic.net.server.ServerSocketReceiver]
16:39:12,119 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
16:39:12,119 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [stdout]
16:39:12,119 |-INFO in ch.qos.logback.classic.net.server.RemoteAppenderServerRunner@228dc826 - listening on 0.0.0.0:6004
16:39:12,120 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
16:39:12,135 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [org.oclc.hadoop.logging.logbacksinksb.service.CrapAppender]
16:39:12,135 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [crap]
16:39:12,136 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
16:39:12,136 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [stdout] to Logger[ROOT]
16:39:12,136 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [crap] to Logger[ROOT]
16:39:12,136 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
16:39:12,136 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@1dd02175 - Registering current configuration as safe fallback point
16:39:12,138 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@23bb8443 - Propagating INFO level on Logger[org.springframework] onto the JUL framework

I can even see that the remote appender has connected to the receiver port (6004):

java      5935 jamiesoh   32u  IPv6 0xaf52811569ae62a3      0t0  TCP localhost:54160->localhost:6004 (ESTABLISHED)
java      6642 jamiesoh   53u  IPv6 0xaf52811569ae5d63      0t0  TCP *:6004 (LISTEN)
java      6642 jamiesoh   54u  IPv6 0xaf5281155d876d63      0t0  TCP localhost:6004->localhost:54160 (ESTABLISHED)

The local appenders only emit local events; the remote appender never reaches the local crap appender.

Any one have any ideas on what is preventing the remote events from passing thru the local appenders?

1 Answers1

0

Just in case this bites someone else, I found the cause. One of the other artifacts had a dependency on logback-classic:1.2.3; the spring-boot version is 1.1.11. Excluding this transitive dependency corrected the problem.

Doctor, heal thyself...