2

This question has been asked few times before and there are some answers but none of them are suitable for the requirement that I have because the answers are directed towards either console appender or File appender.

Formatter config of both these appenders are config driven through standalone or domain xml. However, I'm using json /logstash formatter.

My problem is that the messages sent to stdout or stderr are wrapped by Redhat jboss eap with log level as INFO(irrespective of their level) and each line of a stacktrace is treated as a separate JSON block.

Because of this logstash interprets all messages as INFO rather than warning or errors and it looks very ugly and hard to interprete in kibana.

Snippet of jboss server log.

{
    "timestamp": "2020-02-19T13:19:18.743Z",
    "sequence": 249,
    "loggerClassName": "org.jboss.logmanager.Logger",
    "loggerName": "**stdout**",
    "level": "**INFO**",
    "message": "2020-02-19T14:19:18.000743+0100 [DBQueue_3] **ERROR** **com.uuapp.data** - Invalid operation name in participant message \"Pmsg:Id=0,Sender=0,Consumer=0,ActIndex=0,Oper=null,Flag=0, Priority=8\"",
    "threadName": "DBQueue_3",
    "threadId": 530,
    "mdc": {
    },
    "ndc": "",
    "hostName": "uu-app-18934",
    "processName": "jboss-modules.jar",
    "processId": 22061
}

Is there a way around this annoying feature and make jboss use the logs sent from logback's console appender as is? Atleast combine stacktrace into one json block?

Note that the application uses logback. I'm aware that logback has json formatters which I can use but my hands are tied as the application is kind of a cots product developed in java and uses 3pp jars which are neither updated to use json formatters nor it's allowed to override the war.

So, if there's something to be done has to be done on server side.

Any help is appreciated.

Community
  • 1
  • 1
Sachin
  • 21
  • 3
  • Is there a requirement to use logback? – James R. Perkins Feb 20 '20 at 01:04
  • @JamesR.Perkins, If there was one person whom I was hoping to get an answer from was you as I have referred many of your articles and answers related to Wildfly/Jboss and they have helped me a lot. To answer your question, no, there's no such requirement. Whoever wrote the initial code seem to have chosen logback. – Sachin Feb 20 '20 at 11:12
  • :) The simplest solution would be to not use logback and allow the JBoss EAP to handle the logging configuration. Is that an option? – James R. Perkins Feb 20 '20 at 19:00
  • That's not an option as this application is a COTS product written in java and it can be deployed in other application containers like weblogic So, to keep it consistent they use logback. – Sachin Feb 22 '20 at 21:09
  • One option would be to write a custom logback appender which would get around JBoss EAP wrapping `System.out` by using the `FileDescriptor.out`. As an example this is what we was done for our log4j fork https://github.com/jboss-logging/log4j-jboss-logmanager/blob/master/src/main/java/org/apache/log4j/ConsoleAppender.java#L215-L241. – James R. Perkins Feb 24 '20 at 08:07

1 Answers1

0

Try adding following code in your standalone.xml of Jboss server under logging substem. This happens because log4j2.xml message is wrapped by Jboss's own pattern.

 <subsystem xmlns="urn:jboss:domain:logging:8.0">
 ....
    <console-handler name="stdout-console" autoflush="true">
        <level name="ALL"/>
        <formatter>
            <pattern-formatter pattern="%s%n"/>
        </formatter>
    </console-handler>
    <logger category="stdout" use-parent-handlers="false">
        <handlers>
            <handler name="stdout-console"/>
        </handlers>
    </logger>
....
</substem>
Nilesh Kumar
  • 109
  • 1
  • 5