Search code examples
jsonloggingjbossjboss7.xlogstash

How to configure JBoss AS 7/EAP 6 to log in JSON format?


How would I configure the JBoss log system to use a custom log4j layout like log4j-json or a custom JUL formatter like logstash-util-formatter?

Edit: it looks like custom formatters are available in WildFly 8 and they are coming in EAP 6.3.

In the meantime, I think I have these options which involve bypassing JBoss logging:

  1. Use per-deployment logging to configure log4j myself.
  2. Use jboss-deployment-structure.xml to block EAP's log libraries and use something like logback with a JSON encoder like this.

Either way, I would only get JSON logging for the deployment itself, not for datasources and container startup. Is there another option which would allow all logging to be in JSON format?


Solution

  • It's not possible in JBoss AS 7.x or JBoss EAP 6.2. As you said though it is available in WildFly 8.0.0.Final as a custom-formatter and will be available in JBoss EAP 6.3.

    Actually it is possible, but you'd lose the ability to do runtime changes to the logging configuration. You could remove the logging subsystem and purely use the logging.properties configuration. I'd probably not suggest that unless you desperately need to use the formatter and can't wait for EAP 6.3 or use WildFly.