logstash/log4j-jsonevent-layout

Layout does not work with Log4J2

chadcampbell opened this issue · 11 comments

Hello,

Logstash does not have an input plugin that works with Log4J2. When attempting to use the log4j-jsonevent-layout with an app that uses Log4J2, an error is thrown. That error is:

...contains an invalid element or attribute "layout".

There does not appear to be a workaround for getting log4j2 content into a json format that logstash can understand.

hrmmm. I wonder if I can make this conditional/detectable. It may need to be a new version. I'll investigate.

Was wondering if this is something that is likely to be dealt with in the foreseeable future?

Thanks

created a pullrequest that addresses the issue: #56

Can we expect this to be dealt with anytime soon?

robpc commented

+1

Any updates on this ? is this available ? It's not working for me for log4j2

@batghare the fork-of-a-fork https://github.com/DNSBelgium/log4j-jsonevent-layout works for me for log4j v2, e.g.

<configuration packages="net.logstash.log4j2" monitorInterval="60">
<appenders>
  <Socket name="LogStashSocket" host="logserver01" port="4561" protocol="tcp">
        <JSONEventLayoutV1 userFields="region:us-east-1a, application:myapp">
        </JSONEventLayoutV1>
  </Socket>
</appenders>
<loggers>
    <root level="info"> <!-- We log everything -->
        <appender-ref ref="LogStashSocket"/>
    </root>
</loggers>
</configuration>

Also, in my case (dropping it into an already-built project (storm)) the uber-jar didn't work, likely due to https://issues.apache.org/jira/browse/LOG4J2-673, so I had to manually drop in json-smart-1.1.1.jar and commons-lang-2.6.jar., just FYI. Probably not an issue for one's own code.