简体   繁体   中英

JBOSS EAP 7.2 wraps STDOUT and STDERR messages

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM