[ https://issues.apache.org/jira/browse/LOG4J2-2316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16439501#comment-16439501 ]
Gary Gregory commented on LOG4J2-2316: -------------------------------------- Interesting data point: If you run, the following by itself: {code:java} @Test public void testSetLevel() { Configurator.setLevel("test", Level.DEBUG); } {code} You will _not_ get an NPE and Log4j initializes itself as you can tell from the console message: {noformat} ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2 {noformat} In order for you to get this NPE, there must be some competition between Log4j initializing itself and the call to {{setLevel(String, Level)}}. > NullPointerException while calling Configurator.setLevel() > ---------------------------------------------------------- > > Key: LOG4J2-2316 > URL: https://issues.apache.org/jira/browse/LOG4J2-2316 > Project: Log4j 2 > Issue Type: Bug > Components: Core > Affects Versions: 2.10.0 > Environment: webapplication running in tomcat 8.5 > Reporter: Ranjit Dsouza > Priority: Major > > Hi I want to report an intermittent issue in my webapplication wherein log4j > throws an NPE. > Here is the stack trace: > java.lang.NullPointerException > at > org.apache.logging.log4j.core.config.LoggerConfig.getLevel(LoggerConfig.java:268) > at > org.apache.logging.log4j.core.Logger$PrivateConfig.<init>(Logger.java:384) > at > org.apache.logging.log4j.core.Logger.updateConfiguration(Logger.java:365) > at > org.apache.logging.log4j.core.LoggerContext.updateLoggers(LoggerContext.java:652) > at > org.apache.logging.log4j.core.LoggerContext.updateLoggers(LoggerContext.java:641) > at > org.apache.logging.log4j.core.config.Configurator.setLevel(Configurator.java:296) > at > com.netbackup.logging.util.DebugLoggerFactory.getLogger(DebugLoggerFactory.java:346) > at > com.netbackup.logging.util.DebugLoggerFactory.getLogger(DebugLoggerFactory.java:359) > at > com.netbackup.logging.util.WebServiceLoggerFactory.getLogger(WebServiceLoggerFactory.java:14) > at > com.netbackup.common.logging.LoggerFactory.getLogger(LoggerFactory.java:34) > > Log4j code where the NPE occurs: (LoggerConfig.java) > /** > * Returns the logging Level. > * > * @return the logging Level. > */ > public Level getLevel() > { return level == null ? parent.getLevel() : level; } //This is > the line where the NPE gets thrown > > Inference is parent(LoggerConfig) itself was null. When can this situation > arise? -- This message was sent by Atlassian JIRA (v7.6.3#76005)