You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Alexey Pimenov (JIRA)" <ji...@apache.org> on 2018/06/22 17:20:00 UTC

[jira] [Comment Edited] (LOG4J2-2341) JsonLayout not working with AsyncLoggerContextSelector in 2.11.0

    [ https://issues.apache.org/jira/browse/LOG4J2-2341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16520602#comment-16520602 ] 

Alexey Pimenov edited comment on LOG4J2-2341 at 6/22/18 5:19 PM:
-----------------------------------------------------------------

I've encountered similar but not exact behavior.

my layout:
{code:java}
<JsonLayout stacktraceAsString="true"/>
{code}

in version 2.11.0 with

org.apache.logging.log4j.core.async.RingBufferLogEvent is serialized with only "logEvent" field, like this:

{code:javascript}
{"logEvent": "JWE key management algorithms: [RSA1_5, RSA-OAEP, RSA-OAEP-256, dir, A128KW, A192KW, A256KW, ECDH-ES, ECDH-ES+A128KW, ECDH-ES+A192KW, ECDH-ES+A256KW, PBES2-HS256+A128KW, PBES2-HS384+A192KW, PBES2-HS512+A256KW, A128GCMKW, A192GCMKW, A256GCMKW]" }
{code}

In version 2.10.0 or when I'm not using AsyncLoggerContextSelector - everything works as it should

I believe this is the same issue as LOG4J2-2312


was (Author: aspimenov):
I've encountered similar but not exact behavior.

my layout:
{code:java}
<JsonLayout stacktraceAsString="true"/>
{code}

in version 2.11.0 with

org.apache.logging.log4j.core.async.RingBufferLogEvent is serialized with only "logEvent" field, like this:

{code:javascript}
{"logEvent": "JWE key management algorithms: [RSA1_5, RSA-OAEP, RSA-OAEP-256, dir, A128KW, A192KW, A256KW, ECDH-ES, ECDH-ES+A128KW, ECDH-ES+A192KW, ECDH-ES+A256KW, PBES2-HS256+A128KW, PBES2-HS384+A192KW, PBES2-HS512+A256KW, A128GCMKW, A192GCMKW, A256GCMKW]" }
{code}

In version 2.10.0 or when I'm not using AsyncLoggerContextSelector - everything works as it should

> JsonLayout not working with AsyncLoggerContextSelector in 2.11.0
> ----------------------------------------------------------------
>
>                 Key: LOG4J2-2341
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2341
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.11.0
>            Reporter: Fedor Morozov
>            Priority: Major
>
> In version 2.11.0 appenders with JsonLayout don't output json when Log4jContextSelector is set to org.apache.logging.log4j.core.async.AsyncLoggerContextSelector.
> Here is a sample:
> {code:java}
> package ru.yandex.zen;
> import org.apache.log4j.Logger;
> public class LoggerSample {
>     public static void main(String[] args) {
>         Logger logger = Logger.getLogger("LoggerSample");
>         logger.info("Message 1");
>         logger.info("Message 2");
>     }
> }
> {code}
> {code:java}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="WARN">
>     <Appenders>
>         <RandomAccessFile name="RandomAccessFile" fileName="async.log" immediateFlush="false" append="false">
>             <JsonLayout/>
>         </RandomAccessFile>
>     </Appenders>
>     <Loggers>
>         <Root level="info">
>             <AppenderRef ref="RandomAccessFile"/>
>         </Root>
>     </Loggers>
> </Configuration>
> {code}
> Without AsyncLoggerContextSelector the log looks like this:
> {code:java}
> ""
> ""
> {code}
> Without AsyncLoggerContextSelector:
> {code:java}
> {
> "thread" : "main",
> "level" : "INFO",
> "loggerName" : "LoggerSample",
> "message" : "Message 1",
> "endOfBatch" : false,
> "loggerFqcn" : "org.apache.log4j.Category",
> "instant" : {
> "epochSecond" : 1527061940,
> "nanoOfSecond" : 637000000
> },
> "threadId" : 1,
> "threadPriority" : 5
> }
> {
> "thread" : "main",
> "level" : "INFO",
> "loggerName" : "LoggerSample",
> "message" : "Message 2",
> "endOfBatch" : false,
> "loggerFqcn" : "org.apache.log4j.Category",
> "instant" : {
> "epochSecond" : 1527061940,
> "nanoOfSecond" : 717000000
> },
> "threadId" : 1,
> "threadPriority" : 5
> }
> {code}
> In our main application Json logger outputs the provided message in quotes, not just an empty string. The problem doesn't appear when using asyncRoot or asyncLogger.
> My dependencies:
> {code:java}
> compile 'org.apache.logging.log4j:log4j-api:2.11.0'
> compile 'org.apache.logging.log4j:log4j-core:2.11.0'
> compile "org.apache.logging.log4j:log4j-1.2-api:2.11.0"
> compile "com.fasterxml.jackson.core:jackson-core:2.9.4"
> compile "com.fasterxml.jackson.core:jackson-databind:2.9.4"
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)