Closed srangara123 closed 1 year ago
@srangara123, thanks so much for the report! Fixed for both 2.x
and main
.
@vy - Is this fixed? I'm using log4j2 version 2.19.0 and still getting the same issue.
at java.base/java.util.Objects.requireNonNull(Objects.java:235) at org.apache.logging.log4j.layout.template.json.util.JsonWriter.writeRawString(JsonWriter.java:800) at org.apache.logging.log4j.layout.template.json.resolver.LevelResolver.lambda$createNameResolver$3(LevelResolver.java:144) at org.apache.logging.log4j.layout.template.json.resolver.LevelResolver.resolve(LevelResolver.java:172) at org.apache.logging.log4j.layout.template.json.resolver.LevelResolver.resolve(LevelResolver.java:75) at org.apache.logging.log4j.layout.template.json.resolver.TemplateResolver.resolve(TemplateResolver.java:66) at org.apache.logging.log4j.layout.template.json.resolver.TemplateResolvers$PrefixedFieldResolverMethod.resolve(TemplateResolvers.java:353) at org.apache.logging.log4j.layout.template.json.resolver.TemplateResolvers$MapResolver.resolve(TemplateResolvers.java:409) at org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.encode(JsonTemplateLayout.java:302) at org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.encode(JsonTemplateLayout.java:58) at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.directEncodeEvent(AbstractOutputStreamAppender.java:215) at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.tryAppend(AbstractOutputStreamAppender.java:208) at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.append(AbstractOutputStreamAppender.java:199) at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:161) at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:134) at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:125) at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:89) at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:683) at org.apache.logging.log4j.core.async.AsyncLoggerConfig.callAppenders(AsyncLoggerConfig.java:149) at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:641) at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:624) at org.apache.logging.log4j.core.async.AsyncLoggerConfig.log(AsyncLoggerConfig.java:143) at org.apache.logging.log4j.core.async.AsyncLoggerConfig.logToAsyncLoggerConfigsOnCurrentThread(AsyncLoggerConfig.java:191) at org.apache.logging.log4j.core.async.AsyncLoggerConfigDisruptor$Log4jEventWrapperHandler.onEvent(AsyncLoggerConfigDisruptor.java:112) at org.apache.logging.log4j.core.async.AsyncLoggerConfigDisruptor$Log4jEventWrapperHandler.onEvent(AsyncLoggerConfigDisruptor.java:98) at com.lmax.disruptor.BatchEventProcessor.processEvents(BatchEventProcessor.java:168) at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:125) at java.base/java.lang.Thread.run(Thread.java:840)
@chandrabol as both the release notes and the milestone this issue is labeled with, the fix was delivered with version 2.21.0
. Though note that the most recent Log4j version as of date is 2.24.0
, which you should be using.
Description
We have an application that defines custom Log Levels.
When we use the
JsonTemplateLayout
(https://logging.apache.org/log4j/2.x/manual/json-template-layout.html) we sometimes get a Null pointer ExceptionThis is due to the LevelResolver caching the Levels before we create our custom Log Levels Please refer to the main method below.
Configuration
Version: 2.20.0
Operating system: Windows
JDK: JDK 1.8
Logs
Reproduction
Log4j2.xml file
This last line produces a NPE