logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-1493) Cannot set all loggers as async when using JsonLayout
Date Fri, 05 Aug 2016 05:23:20 GMT

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

Gary Gregory commented on LOG4J2-1493:
--------------------------------------

I updated the test {{org.apache.logging.log4j.core.appender.JsonCompleteFileAppenderTest}}
to be parameterized with {{ContextSelectors}} including the {{AsyncLoggerContextSelector}}
but the NPE does not happen. We need a better test.

Can you provide another test method in {{JsonCompleteFileAppenderTest}}?

Note that this test does not use the Kafka appender.

> Cannot set all loggers as async when using JsonLayout
> -----------------------------------------------------
>
>                 Key: LOG4J2-1493
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1493
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Layouts
>    Affects Versions: 2.6.2
>         Environment: all
>            Reporter: Jose Leon
>
> When I set this property:
> {noformat}
> -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
> {noformat}
> And use KafkaAppender like so:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8" ?>
> <Configuration status="warn">
>   <Appenders>
>     <Kafka name="kafka" topic="${sys:kafka.topic}">
>       <JsonLayout properties="true" locationInfo="true" complete="false" compact="true"
/>
>       <Property name="bootstrap.servers">${sys:kafka.destinations}</Property>
>       <Property name="hostname">${sys:hostname}</Property>
>       <Property name="port">${sys:port}</Property>
>       <Property name="instance">${sys:instance}</Property>
>     </Kafka>
>   </Appenders>
>   <Loggers>
>     <Logger name="org.apache.kafka" level="INFO" />
>     <Root level="${sys:log.level}">
>       <AppenderRef ref="kafka"/>
>     </Root>
>   </Loggers>
> </Configuration>
> {code}
> I get this stacktrace and no appenders work; with the goal being to get the KafkaAppender
working at minimum
> {noformat}
> 2016-08-03 20:31:15,607 Log4j2-AsyncLogger[AsyncContext@764c12b6]1 ERROR com.fasterxml.jackson.databind.JsonMappingException:
(was java.lang.NullPointerException) (through reference chain: org.apache.logging.log4j.core.async.RingBufferLogEvent["formattedMessage"])
com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException)
(through reference chain: org.apache.logging.log4j.core.async.RingBufferLogEvent["formattedMessage"])
>         at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210)
>         at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177)
>         at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:190)
>         at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFieldsFiltered(BeanSerializerBase.java:724)
>         at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:154)
>         at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:129)
>         at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1052)
>         at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:905)
>         at org.apache.logging.log4j.core.layout.AbstractJacksonLayout.toSerializable(AbstractJacksonLayout.java:83)
>         at org.apache.logging.log4j.core.layout.JsonLayout.toSerializable(JsonLayout.java:937)
>         at org.apache.logging.log4j.core.layout.AbstractJacksonLayout.toSerializable(AbstractJacksonLayout.java:63)
>         at org.apache.logging.log4j.core.layout.JsonLayout.toSerializable(JsonLayout.java:801)
>         at org.apache.logging.log4j.core.layout.AbstractJacksonLayout.toSerializable(AbstractJacksonLayout.java:33)
>         at org.apache.logging.log4j.core.layout.AbstractStringLayout.toByteArray(AbstractStringLayout.java:253)
>         at org.apache.logging.log4j.core.appender.mom.kafka.KafkaAppender.append(KafkaAppender.java:80)
>         at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:155)
>         at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:128)
>         at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:119)
>         at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
>         at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:390)
>         at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:375)
>         at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:359)
>         at org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:79)
>         at org.apache.logging.log4j.core.async.AsyncLogger.actualAsyncLog(AsyncLogger.java:309)
>         at org.apache.logging.log4j.core.async.RingBufferLogEvent.execute(RingBufferLogEvent.java:149)
>         at org.apache.logging.log4j.core.async.RingBufferLogEventHandler.onEvent(RingBufferLogEventHandler.java:45)
>         at org.apache.logging.log4j.core.async.RingBufferLogEventHandler.onEvent(RingBufferLogEventHandler.java:29)
>         at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:128)
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>         at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.NullPointerException
>         at org.apache.logging.log4j.core.async.RingBufferLogEvent.getFormattedMessage(RingBufferLogEvent.java:213)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:498)
>         at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:536)
>         at com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter.serializeAsField(SimpleBeanPropertyFilter.j
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message