logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Magnusson <alexander.magnus...@netset.com>
Subject Async logger context selector creates a throwable in JSON layout
Date Fri, 11 May 2018 14:46:57 GMT
I'm currently migrating our codebase to Log4j2 (2.9.1) in a Tomcat 9.0.7
environment, and while testing different configurations I noticed a weird,
what i think also undocumented, difference between the standard usage and
when starting with -DLog4jContextSelector=org.apa

My test setup for logging is just a plain RootLogger sending to a
FileAppender with a JsonLayout.
The Layout is configured as follows:
<File name="TESTOUT" fileName="/home/a/temp/log4j2/testjsonout2.log">
            <JsonLayout compact="true" properties="true" eventEol="true"
includeStacktrace="true" locationInfo="false" stacktraceAsString="true"/>
<Null name="devnull"/>

And the loggers as usual:
        <Logger name="com.zaxxer.hikari" level="DEBUG" additivity="false">
            <AppenderRef ref="devnull"/>
        <Root level="info">
            <Property name="m4dump">true</Property>
            <AppenderRef ref="TESTOUT" level="INFO"/>

because I only want the stacktrace as a string and not as a nested object.
This works fine with the default Selector, but when using the Async there
is an extra object "throwable", in addition to the normal "thrown",
included no matter what settings I set. The "throwable" has the stacktrace
as you'd see it if it was included but not as a string.

I guess it has something to do with providing the locationInfo to appenders
and layouts, but it's set to false. I also have a custom context data
injector but I dont see how that is the cause of the problem.
Is this intended?

This is a part of the JSON printed with the AsyncLogger where the
"throwable" gets included:

    "timeMillis": 1526044197778,
    "thread": "https-openssl-apr-8443-exec-5",
    "level": "WARN",
    "loggerName": "se.netset.servlet.EncodingFilter",
    "message": "TEST",
        "commonElementCount": 0,
        "localizedMessage": "FISRST",
        "message": "FISRST",
        "name": "java.lang.Exception",
        "extendedStackTrace": "java.lang.Exception: FISRST\n\tat
~[classes/:?]\n\tat org.apache.catalina.core.ApplicationFilterChain.
~[catalina.jar:9.0.7]\n\tat org.apache.catalina.core.ApplicationFilterChain.
doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:9.0.7]\n\tat
    "endOfBatch": true,
    "parameterCount": 0,
        "stackTrace": [
            "class": "se.netset.servlet.EncodingFilter",
            "method": "doFilter",
            "file": "EncodingFilter.java",
            "line": 35
            "class": "org.apache.catalina.core.ApplicationFilterChain",
            "method": "internalDoFilter",
            "file": "ApplicationFilterChain.java",
            "line": 193


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message