1

I'm trying to use Chainsaw v2 from http://people.apache.org/~sdeboy I don't want to use zero configuration. Just a simple socketAppender/SocketReceiver combo.

I'm using log4j2 with the following configuration

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" >
    <Appenders>
        <Console name="CONSOLE" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
        <Socket name="SharathZeroConf" host="localhost" port="4445">
        </Socket>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <AppenderRef ref="SharathZeroConf" />
            <AppenderRef ref="CONSOLE" />
        </Root>

    </Loggers>
</Configuration>

On ChainSaw, I'm selecting the option "Receive events from network" with port 4445.

However chainsaw doesnt log anything.

I've verified that the appender configuration is correct on log4j side by using the builtin socketserver

java -cp ~/.m2/reposiry/org/apache/logging/log4j/log4j-api/2.0.2/log4j-api-2.0.2.jar  org.apache.logging.log4j.core.net.server.TcpSocketServer 4445

So the bug must be on chainsaw side. Any pointers @Scott ?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
sha
  • 614
  • 6
  • 16
  • 1
    After looking at the source code of chainsaw, it looks like chainsaw still uses log4j 1.x and has very limited support for log4j2. In particular, it casts incoming log events from socket as log4j 1.x `org.apache.log4j.spi.LoggingEvent` whereas the log4j2 events that are sent are actually `org.apache.logging.log4j.core.LogEvent` objects – sha Sep 26 '14 at 22:43

1 Answers1

2

You're right, I got the same issue. I just tried with LogMX instead, and it works like a charm:

LogMX screenshot

I just had to copy Log4j JARs in LogMX lib/ directory (i.e. log4j-api-2.xx.jar and log4j-core-2.xx.jar)

xav
  • 5,452
  • 7
  • 48
  • 57
  • Wow, awesome, thanks. I'll try it out. I wonder if LogMX explicitly supports log4j2 or its simply working 'by chance' – sha Sep 26 '14 at 22:40
  • I have a weird problem where logmx captures my application logs but doesnt capture spring logs. I can see them in the console though. Also FYI for other people planning to use logmx, the free version limits you to 10,000 logs – sha Sep 29 '14 at 02:48
  • You may want to check your Log4j configuration: the appender used for Spring logs may not be the same as for your application logs (i.e. not a `Socket Appender`), you may want to check your Loggers/Appenders and their `additivity`. Spring logs may also be filtered by package name for Socket Appender through [Log4j `filters`](http://logging.apache.org/log4j/2.x/manual/configuration.html#Filters). – xav Sep 29 '14 at 17:01