log4j2 LoggerContext not showing up in JMX Gui or JConsole - java

My Google foo is letting me down today! I am trying to configure log4j2 so that I can access the loggers via JMX and change their log levels.
However, when I hook everything up, none of the loggers show up in the JMX tree (or log4j-jmx-gui) as shown in the log4j2 JMX docs. Only the log4j2 ContextSelector and StatusLogger in the JConsole attribute tree and the StatusLogger tab in the log4j-jmx-gui (stand-alone or as a plugin) show up. No LoggerContext elements.
I've googled and not come up with anything! That probably means I'm missing something somewhere. Any help would be greatly appreciated by me and wall which I'm banging my head against :)
I'm using Log4j2 beta9 with Java 1.6.0_45-b06 on win7. I have tried it on Java 7 and it results in the same behaviour.
The log4j2 dependencies being used:
log4j-api-2.0-beta9.jar
log4j-core-2.0-beta9.jar
My log4j2.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="debug">
<Appenders>
<Console name="log-test" target="SYSTEM_OUT">
<PatternLayout pattern="%d{DATE} %-5p LJX2 %c{1}: %m%n" />
</Console>
</Appenders>
<Loggers>
<Logger name="top.Log4J2TestApp" level="debug" additivity="false">
<AppenderRef ref="log-test" />
</Logger>
<Root level="trace">
<AppenderRef ref="log-test" />
</Root>
</Loggers>
</Configuration>
My test program:
package top;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Log4J2TestApp {
public static void main(String[] args) {
System.out.println("******** Started ZZZ ****************");
Logger log = LogManager.getLogger(Log4J2TestApp.class);
int cnt = 0;
while (true) {
log.warn("=========== Test message: {} ================", cnt++);
Thread.sleep(1000);
}
}
}
The output of the test program looks like this:
******** Started ZZZ ****************
2013-11-06 15:07:29,720 DEBUG Generated plugins in 0.000020959 seconds
2013-11-06 15:07:29,733 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d{DATE} %-5p LJX2 %c{1}: %m%n", Configuration(log4j2.xml), null, charset="null",alwaysWriteExceptions="null")
2013-11-06 15:07:29,735 DEBUG Generated plugins in 0.000013687 seconds
2013-11-06 15:07:29,737 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%d{DATE} %-5p LJX2 %c{1}: %m%n), null, target="SYSTEM_OUT", name="log-test",follow="null", ignoreExceptions="null")
2013-11-06 15:07:29,739 DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream2013-11-06 15:07:29,740 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element Appenders with params(Appenders={log-test})
2013-11-06 15:07:29,742 DEBUG Generated plugins in 0.000012832 seconds
2013-11-06 15:07:29,743 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element AppenderRef with params(ref="log-test", level="null", null)
2013-11-06 15:07:29,746 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element Logger with params(additivity="false", level="debug", name="top.Log4J2TestApp", includeLocation="null", AppenderRef={log-test}, Properties={}, Configuration(log4j2.xml), null)
2013-11-06 15:07:29,749 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element AppenderRef with params(ref="log-test", level="null", null)
2013-11-06 15:07:29,751 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element Root with params(additivity="null", level="trace", includeLocation="null", AppenderRef={log-test}, Properties={}, Configuration(log4j2.xml), null)
2013-11-06 15:07:29,754 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPluginfor element Loggers with params(Loggers={top.Log4J2TestApp, root})
2013-11-06 15:07:29,755 DEBUG Reconfiguration completed
06 Nov 2013 15:07:29,763 WARN LJX2 Log4J2TestApp: =========== Test message: 0 ================
....
06 Nov 2013 15:07:36,766 WARN LJX2 Log4J2TestApp: =========== Test message: 7 ================
2013-11-06 15:07:51,450 DEBUG ServletContext not present - WebLookup not added
2013-11-06 15:07:51,451 DEBUG Shutting down OutputStreamManager SYSTEM_OUT
The StatusLogger tab in the log4j-jmx-gui does have one exception but it would seem to have nothing to do with the loggers.
2013-11-06 15:41:01,403 WARN Multiple logging implementations found:
Factory: org.apache.logging.log4j.core.impl.Log4jContextFactory, Weighting: 10
Using factory: org.apache.logging.log4j.core.impl.Log4jContextFactory
2013-11-06 15:41:01,505 WARN JmDNS or serviceInfo class not found java.lang.ClassNotFoundException: javax.jmdns.JmDNS
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at org.apache.logging.log4j.core.net.MulticastDNSAdvertiser.initializeJMDNS(MulticastDNSAdvertiser.java:228)
at org.apache.logging.log4j.core.net.MulticastDNSAdvertiser.<clinit>(MulticastDNSAdvertiser.java:41)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at org.apache.logging.log4j.core.config.plugins.PluginManager.decode(PluginManager.java:241)
at org.apache.logging.log4j.core.config.plugins.PluginManager.collectPlugins(PluginManager.java:152)
at org.apache.logging.log4j.core.config.plugins.PluginManager.collectPlugins(PluginManager.java:130)
at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:116)
at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:102)
at org.apache.logging.log4j.core.layout.PatternLayout.createPatternParser(PatternLayout.java:183)
at org.apache.logging.log4j.core.layout.PatternLayout.<init>(PatternLayout.java:115)
at org.apache.logging.log4j.core.layout.PatternLayout.createLayout(PatternLayout.java:219)
at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:51)
at org.apache.logging.log4j.core.LoggerContext.<init>(LoggerContext.java:63)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:217)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:114)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:81)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:83)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:34)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:387)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:332)
at top.Log4J2TestApp.main(Log4J2TestApp.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
2013-11-06 15:41:01,612 DEBUG Generated plugins in 0.000017537 seconds
2013-11-06 15:41:01,625 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d{DATE} %-5p LJX2 %c{1}: %m%n", Configuration(log4j2.xml), null, charset="null", alwaysWriteExceptions="null")
2013-11-06 15:41:01,627 DEBUG Generated plugins in 0.000011977 seconds
2013-11-06 15:41:01,629 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%d{DATE} %-5p LJX2 %c{1}: %m%n), null, target="SYSTEM_OUT", name="log-test", follow="null", ignoreExceptions="null")
2013-11-06 15:41:01,631 DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream
2013-11-06 15:41:01,632 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element Appenders with params(Appenders={log-test})
2013-11-06 15:41:01,633 DEBUG Generated plugins in 0.000011977 seconds
2013-11-06 15:41:01,635 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element AppenderRef with params(ref="log-test", level="null", null)
2013-11-06 15:41:01,637 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element Logger with params(additivity="false", level="debug", name="top.Log4J2TestApp", includeLocation="null", AppenderRef={log-test}, Properties={}, Configuration(log4j2.xml), null)
2013-11-06 15:41:01,640 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element AppenderRef with params(ref="log-test", level="null", null)
2013-11-06 15:41:01,642 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element Root with params(additivity="null", level="trace", includeLocation="null", AppenderRef={log-test}, Properties={}, Configuration(log4j2.xml), null)
2013-11-06 15:41:01,644 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element Loggers with params(Loggers={top.Log4J2TestApp, root})
2013-11-06 15:41:01,646 DEBUG Reconfiguration completed

Your config looks good, the only thing a bit suspicious is the error. The error does seem to occur in the LoggerContext constructor, so it may be related after all.
You may have found a bug. Would you mind reporting this issue in the log4j2 issue tracker so the log4j team can look at it?

Log4j2 uses ClassLoaderContextSelector as ContextSelector by default. In some cases (it is not clear for me, may be for simple applications like yours) it returns nothing as getLoggerContexts() method call result. No logger contexts - nothing no show, so LoggerContext category doesn't present in the tree. It can be fixed by selecting another ContextSelector implementation. I used org.apache.logging.log4j.core.selector.BasicContextSelector for this purpose. It can be set using system property named "Log4jContextSelector". See docs for more info.
It solves my problem, I hope it helps to solve yours too.

Related

WireMock unable to set log4j level to INFO instead of DEBUG

I'm running JUnit testcases with WireMock. Embedded Jetty Server is configured as follows.
#Before
public void setup() {
final ResponseTemplateTransformer theTemplateTransformer =
new ResponseTemplateTransformer(false);
templateTransformerName = theTemplateTransformer.getName();
mWireMockServer = new WireMockServer(
WireMockConfiguration
.options()
.notifier(new ConsoleNotifier(false))
.extensions(theTemplateTransformer));
mWireMockServer.start();
}
The output of the setup() method alone is very verbose, about 200 lines long. It starts like this:
> Task :processResources
> Task :classes
> Task :compileTestJava
> Task :processTestResources
> Task :testClasses
> Task :test
log4j: Threshold ="null".
log4j: Level value for root is [DEBUG].
log4j: root level set to DEBUG
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Setting property [immediateFlush] to [true].
log4j: Setting property [threshold] to [ALL].
log4j: Setting property [target] to [System.out].
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss.SSS} [%5p] [%t] [%c{1}] [%F:%L] [%X{uuid}] - %m%n].
log4j: Adding appender named [ConsoleAppender] to category [root].
2019-12-09 11:28:06.813 [DEBUG] [Test worker] [log] [Log.java:159] [] - Logging to org.slf4j.impl.Log4jLoggerAdapter(wiremock.org.eclipse.jetty.util.log) via wiremock.org.eclipse.jetty.util.log.Slf4jLog
2019-12-09 11:28:06.820 [ INFO] [Test worker] [log] [Log.java:169] [] - Logging initialized #1394ms to wiremock.org.eclipse.jetty.util.log.Slf4jLog
2019-12-09 11:28:06.841 [DEBUG] [Test worker] [ContainerLifeCycle] [ContainerLifeCycle.java:412] [] - Server#2173e69b{STOPPED}[9.4.20.v20190813] added {QueuedThreadPool[qtp547179568]#209d4c30{STOPPED,8<=0<=14,i=0,r=-1,q=0}[NO_TRY],AUTO}
2019-12-09 11:28:06.856 [DEBUG] [Test worker] [ContainerLifeCycle] [ContainerLifeCycle.java:412] [] - HttpConnectionFactory#4f25c098[HTTP/1.1] added {HttpConfiguration#613f727b{32768/8192,8192/8192,https://:0,[]},POJO}
2019-12-09 11:28:06.864 [DEBUG] [Test worker] [ContainerLifeCycle] [ContainerLifeCycle.java:412] [] - NetworkTrafficServerConnector#5a238421{null,[]}{0.0.0.0:0} added {Server#2173e69b{STOPPED}[9.4.20.v20190813],UNMANAGED}
2019-12-09 11:28:06.865 [DEBUG] [Test worker] [ContainerLifeCycle] [ContainerLifeCycle.java:412] [] - NetworkTrafficServerConnector#5a238421{null,[]}{0.0.0.0:0} added {QueuedThreadPool[qtp547179568]#209d4c30{STOPPED,8<=0<=14,i=0,r=-1,q=0}[NO_TRY],AUTO}
2019-12-09 11:28:06.865 [DEBUG] [Test worker] [ContainerLifeCycle] [ContainerLifeCycle.java:412] [] - NetworkTrafficServerConnector#5a238421{null,[]}{0.0.0.0:0} added {ScheduledExecutorScheduler#5839ea4{STOPPED},AUTO}
2019-12-09 11:28:06.866 [DEBUG] [Test worker] [ContainerLifeCycle] [ContainerLifeCycle.java:412] [] - NetworkTrafficServerConnector#5a238421{null,[]}{0.0.0.0:0} added {wiremock.org.eclipse.jetty.io.ArrayByteBufferPool#f73022f,POJO}
I do not want to print out DEBUG logs, just INFO level stuff. I tried to do this by changing the WireMock Configuration as follows. What I'm doing is described in the official documentation, section Notification (logging), so feel free to have a look.
.notifier(new ConsoleNotifier(false)) //attribute verbose is set to false
Also tried to solve this by adding a log4j.properties file under src/test/resources/
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.logger.org.apache.http.wire=INFO
Can someone help me please?
This worked in my case (Spring, Logback) - src/test/resources/logback-test.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<!-- Decrease amount of logs from Jetty started by WireMock -->
<logger name="org.eclipse.jetty" level="info"/>
<logger name="org.eclipse.jetty.server.handler.ContextHandler" level="warn"/>
</configuration>

Log4J does not want to create logfile

In my project I use Log4j to process all logging. The config I use:
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d - %-5p %-10c - %m%n"/>
</Console>
<File name="file" fileName="logs/TAF_${sys:current_date}.log">
<PatternLayout>
<Pattern>%d{yyyy-mm-dd_HH:mm:ss.SSS} - %-5p %-10c - %m%n</Pattern>
</PatternLayout>
</File>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="file" level="DEBUG"/>
<AppenderRef ref="STDOUT" level="DEBUG"/>
</Root>
</Loggers>
The error I get:
2018-11-19 16:12:59,531 main ERROR FileManager (logs\TAF_${sys:current_date}.log) java.io.IOException: De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist java.io.IOException: De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist
at java.base/java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.base/java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:432)
at java.base/java.io.File.getCanonicalPath(File.java:618)
at java.base/java.io.File.getCanonicalFile(File.java:643)
at org.apache.logging.log4j.core.util.FileUtils.makeParentDirs(FileUtils.java:142)
at org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory.createManager(FileManager.java:418)
at org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory.createManager(FileManager.java:406)
at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
at org.apache.logging.log4j.core.appender.FileManager.getFileManager(FileManager.java:180)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:95)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:51)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at nl.*****.Apl.<clinit>(Apl.java:9)
2018-11-19 16:12:59,536 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.FileAppender for element File: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory#1ffaf86] unable to create manager for [logs\TAF_${sys:current_date}.log] with data [org.apache.logging.log4j.core.appender.FileManager$FactoryData#6574a52c] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory#1ffaf86] unable to create manager for [logs\TAF_${sys:current_date}.log] with data [org.apache.logging.log4j.core.appender.FileManager$FactoryData#6574a52c]
at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:115)
at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
at org.apache.logging.log4j.core.appender.FileManager.getFileManager(FileManager.java:180)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:95)
at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:51)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at nl.*****.Apl.<clinit>(Apl.java:9)
2018-11-19 16:12:59,541 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.FileAppender for element File: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.FileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.FileAppender
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:235)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at nl.******.Apl.<clinit>(Apl.java:9)
2018-11-19 16:12:59,543 main ERROR Null object returned for File in Appenders.
2018-11-19 16:12:59,550 main ERROR Unable to locate appender "file" for logger config "root"
The first error is in dutch, which translates to: "The filename, directory name, or volume label syntax is incorrect".
This Log4J config file is used under an Ubuntu environment and works perfectly. Now I have added a Win10 machine to the pool, but I receive this error.
What am I doing wrong?
I tried to make the path absolute, "c:/Project/logs/TAF_${sys:current_date}.log", but it did not solve the problem. Every user has read/write access to the logs directory.
Other stuff I tried:
Log4j logfile error FileNotFoundException
#edit:
For what I can see, it looks like log4j is trying to create a file named "TAF_${sys:current_date}.log". That ofcourse doesn't work, because { and } are not valid for filenames. When the "_${sys:current_date}" is removed, I am able to create the log file. How am I able to use the expression again, to add the current date/time?
#edit2:Found the answer here. I needed to set the system property "current_date" in the code.

log4j2 shuts down all appenders with slf4j

I could use some help with my log4j2 configuration. When I debug the logger, it looks like it shuts down all of the appenders, and then I never receive any application logs. Luckily I know that log4j is at least finding the properties file and giving logger initialization debug output.
Here is my log4j2.properties file:
status = debug
name = PropertiesConfig
filters = threshold
filter.threshold.type = ThresholdFilter
filter.threshold.level = info
appenders = console
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{yy-MM-dd HH:mm:ss:SSS} %-5p %c{1}:%L - %m%n
rootLogger.level = debug
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT
appender.file.type = File
appender.file.name = application
appender.file.fileName=${filename}/propertieslogs.log
appender.file.layout.type=PatternLayout
appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
Here is the logger debug init output:
DEBUG Starting LoggerContext[name=ROOT] from configuration at null
DEBUG Starting LoggerContext[name=ROOT, org.apache.logging.log4j.core.LoggerContext#448dc39b] with configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration#70ffa0b4...
DEBUG Shutdown hook enabled. Registering a new one.
DEBUG Apache Log4j Core 2.11.1 initializing configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration#70ffa0b4
DEBUG Installed 1 script engine
DEBUG Oracle Nashorn version: 1.8.0_162, language: ECMAScript, threading: Not Thread Safe, compile: true, names: [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory
DEBUG PluginManager 'Core' found 118 plugins
DEBUG PluginManager 'Level' found 0 plugins
DEBUG PluginManager 'Lookup' found 14 plugins
DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
DEBUG PluginManager 'TypeConverter' found 26 plugins
DEBUG createAppenderRef(ref="STDOUT", level="null", Filter=null)
DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
DEBUG createLogger(additivity="null", level="DEBUG", includeLocation="null", ={STDOUT}, ={}, Configuration(PropertiesConfig), Filter=null)
DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
DEBUG createLoggers(={root})
DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
DEBUG PatternLayout$Builder(pattern="%d{yy-MM-dd HH:mm:ss:SSS} %-5p %c{1}:%L - %m%n", PatternSelector=null, Configuration(PropertiesConfig), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
DEBUG PluginManager 'Converter' found 44 plugins
DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender].
DEBUG ConsoleAppender$Builder(target="null", follow="null", direct="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%d{yy-MM-dd HH:mm:ss:SSS} %-5p %c{1}:%L - %m%n), name="STDOUT", Configuration(PropertiesConfig), Filter=null)
DEBUG Starting OutputStreamManager SYSTEM_OUT.false.false
DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
DEBUG createAppenders(={STDOUT})
DEBUG Building Plugin[name=filter, class=org.apache.logging.log4j.core.filter.ThresholdFilter].
DEBUG createFilter(level="INFO", onMatch="null", onMismatch="null")
DEBUG Configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration#70ffa0b4 initialized
DEBUG Starting configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration#70ffa0b4
DEBUG Started configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration#70ffa0b4 OK.
DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false-1
DEBUG Shut down OutputStreamManager SYSTEM_OUT.false.false-1, all resources released: true
DEBUG Appender DefaultConsole-1 stopped with status true
DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration#605d8cc OK
DEBUG Registering MBean org.apache.logging.log4j2:type=ROOT
DEBUG Registering MBean org.apache.logging.log4j2:type=ROOT,component=StatusLogger
DEBUG Registering MBean org.apache.logging.log4j2:type=ROOT,component=ContextSelector
DEBUG Registering MBean org.apache.logging.log4j2:type=ROOT,component=Loggers,name=
DEBUG Registering MBean org.apache.logging.log4j2:type=ROOT,component=Appenders,name=STDOUT
DEBUG org.apache.logging.log4j.core.util.SystemClock does not support precise timestamps.
DEBUG LoggerContext[name=ROOT, org.apache.logging.log4j.core.LoggerContext#448dc39b] started OK with configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration#70ffa0b4.
DEBUG Log4jServletContextListener ensuring that Log4j starts up properly.
DEBUG Log4jServletContextListener ensuring that Log4j shuts down properly.
DEBUG Removing LoggerContext for [ROOT].
DEBUG Stopping LoggerContext[name=ROOT, org.apache.logging.log4j.core.LoggerContext#448dc39b]...
DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false
DEBUG Shut down OutputStreamManager SYSTEM_OUT.false.false, all resources released: true
DEBUG Appender STDOUT stopped with status true
DEBUG Stopped org.apache.logging.log4j.core.config.properties.PropertiesConfiguration#70ffa0b4 OK
DEBUG Stopped LoggerContext[name=ROOT, org.apache.logging.log4j.core.LoggerContext#448dc39b] with status true
Thanks for any help! I need it.
I'd really like to get the async appenders working at some point, but its hard to find examples via the log4j2.properties syntax for log4j2
P.S. - here is my pom.xml:
<!-- log4j is used for logging within the application -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.11.1</version>
<scope>runtime</scope>
</dependency>
<!-- slf4j is used to tie Spring to log4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.25</version>
</dependency>
I just experienced what seems to be a similar problem. In my case, I was able to receive application logs, but with what appeared to be a default log4j2 config. The logs were INFO level. None of the levels set for loggers in the log4j2 config (XML) were being applied. I saw a very similar output in the startup logs as posted by the OP, including the message about "shutting down OutputStreamManager".
Mine is a spring-boot application and I was able to resolve the problem by disabling the spring-boot LoggingSystem. I added this system variable to my startup command:
-Dorg.springframework.boot.logging.LoggingSystem=none
Once I did that, the logging worked as expected, according to the levels set in my log4j2 XML config. It appears to be spring-boot hijacking the log system, rather than a conflict between SLF4J an LOG4J2.
Note that I still see the same logging startup messages -- the OutputStreamManager is still shutting down. Speculation: this is normal behavior, possibly just shutting down the bootstrap logger that prints the log4j2 initialization process.
Versions:
log4j: 2.13.3
slf4j: 1.7.30
spring-boot: 2.2.7-RElEASE

Unable to invoke factory method in class class org.apache.logging.log4j.core.layout.JsonLayout for element JsonLayout

I am trying to log in JSON format through log4j2.
This is my log4j2.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug" name="MyApp" packages="org.apache.logging.log4j.core.layout.JSONLayout">
<Appenders>
<RollingRandomAccessFile name="RollingRandomAccessFile" fileName="logs/app3.log"
filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz" append="false">
<JsonLayout/>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="RollingRandomAccessFile"/>
</Root>
</Loggers>
</Configuration>
These are the dependencies I have used:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>net.logstash.log4j</groupId>
<artifactId>jsonevent-layout</artifactId>
<version>1.7</version>
</dependency><dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
When I run the program I get an error as follows:
543 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.layout.JsonLayout for element JsonLayout.
Debug:
2016-05-09 16:06:04,909 main DEBUG Initializing configuration XmlConfiguration[location=/home/mrunal/repo/jigsaw/jigsaw/jigsaw-solution/jigsaw-matchmanager-business/target/classes/log4j2.xml]
2016-05-09 16:06:04,916 main DEBUG Installed script engines
2016-05-09 16:06:05,717 main DEBUG Oracle Nashorn Version: 1.8.0_91, Language: ECMAScript, Threading: Not Thread Safe, Compile: true, Names: {nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript}
2016-05-09 16:06:05,823 main DEBUG Took 0.104995 seconds to load 14 plugins from package org.apache.logging.log4j.core.layout
2016-05-09 16:06:05,824 main DEBUG PluginManager 'Core' found 97 plugins
2016-05-09 16:06:05,824 main DEBUG PluginManager 'Level' found 0 plugins
2016-05-09 16:06:05,831 main DEBUG No scheduled items
2016-05-09 16:06:05,835 main DEBUG PluginManager 'Lookup' found 13 plugins
2016-05-09 16:06:05,837 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.JsonLayout].
2016-05-09 16:06:05,853 main DEBUG PluginManager 'TypeConverter' found 23 plugins
2016-05-09 16:06:05,863 main DEBUG createLayout(locationInfo="false", properties="false", complete="false", compact="false", eventEol="false", charset="UTF-8")
2016-05-09 16:06:05,864 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.layout.JsonLayout for element JSONLayout.
2016-05-09 16:06:05,865 main DEBUG Building Plugin[name=TimeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy].
2016-05-09 16:06:05,867 main DEBUG createPolicy(interval="null", modulate="null")
2016-05-09 16:06:05,868 main DEBUG Building Plugin[name=SizeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy].
2016-05-09 16:06:05,869 main DEBUG createPolicy(size="250 MB")
2016-05-09 16:06:05,872 main DEBUG Building Plugin[name=Policies, class=org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy].
2016-05-09 16:06:05,882 main DEBUG createPolicy(={TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=false), SizeBasedTriggeringPolicy(size=262144000)})
2016-05-09 16:06:05,882 main DEBUG Building Plugin[name=DefaultRolloverStrategy, class=org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy].
2016-05-09 16:06:05,887 main DEBUG createStrategy(max="20", min="null", fileIndex="null", compressionLevel="null", ={}, stopCustomActionsOnError="true", Configuration(/home/mrunal/repo/jigsaw/jigsaw/jigsaw-solution/jigsaw-matchmanager-business/target/classes/log4j2.xml))
2016-05-09 16:06:05,888 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender].
2016-05-09 16:06:05,892 main DEBUG createAppender(fileName="logs/app3.log", filePattern="logs/${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz", append="false", name="RollingRandomAccessFile", immediateFlush="null", bufferSize="null", Policies(CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=false), SizeBasedTriggeringPolicy(size=262144000)])), DefaultRolloverStrategy(DefaultRolloverStrategy(min=1, max=20)), JSONLayout(null), Filter=null, ignoreExceptions="null", advertise="null", advertiseURI="null", Configuration(/home/mrunal/repo/jigsaw/jigsaw/jigsaw-solution/jigsaw-matchmanager-business/target/classes/log4j2.xml))
2016-05-09 16:06:05,893 main INFO Log4j appears to be running in a Servlet environment, but there's no log4j-web module available. If you want better web container support, please add the log4j-web JAR to your web archive or server lib directory.
2016-05-09 16:06:05,894 main DEBUG PluginManager 'Converter' found 38 plugins
2016-05-09 16:06:05,895 main DEBUG Starting OutputStreamManager SYSTEM_OUT.false-2
2016-05-09 16:06:05,909 main DEBUG Starting RollingRandomAccessFileManager logs/app3.log
2016-05-09 16:06:05,914 main DEBUG PluginManager 'FileConverter' found 2 plugins
2016-05-09 16:06:05,935 main DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
2016-05-09 16:06:05,936 main DEBUG createAppenders(={RollingRandomAccessFile})
2016-05-09 16:06:05,936 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2016-05-09 16:06:05,937 main DEBUG createAppenderRef(ref="RollingRandomAccessFile", level="null", Filter=null)
2016-05-09 16:06:05,937 main DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
2016-05-09 16:06:05,938 main DEBUG createLogger(additivity="null", level="TRACE", includeLocation="null", ={RollingRandomAccessFile}, ={}, Configuration(/home/mrunal/repo/jigsaw/jigsaw/jigsaw-solution/jigsaw-matchmanager-business/target/classes/log4j2.xml), Filter=null)
2016-05-09 16:06:05,941 main DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
2016-05-09 16:06:05,943 main DEBUG createLoggers(={root})
2016-05-09 16:06:05,944 main DEBUG Configuration XmlConfiguration[location=/home/mrunal/repo/jigsaw/jigsaw/jigsaw-solution/jigsaw-matchmanager-business/target/classes/log4j2.xml] initialized
2016-05-09 16:06:05,952 main DEBUG Starting configuration XmlConfiguration[location=/home/mrunal/repo/jigsaw/jigsaw/jigsaw-solution/jigsaw-matchmanager-business/target/classes/log4j2.xml]
2016-05-09 16:06:05,952 main DEBUG Started configuration XmlConfiguration[location=/home/mrunal/repo/jigsaw/jigsaw/jigsaw-solution/jigsaw-matchmanager-business/target/classes/log4j2.xml] OK.
2016-05-09 16:06:05,953 main DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false-1
2016-05-09 16:06:05,953 main DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration#7de26db8 OK
2016-05-09 16:06:06,027 main DEBUG Registering MBean org.apache.logging.log4j2:type=1a6c5a9e
2016-05-09 16:06:06,030 main DEBUG Registering MBean org.apache.logging.log4j2:type=1a6c5a9e,component=StatusLogger
2016-05-09 16:06:06,032 main DEBUG Registering MBean org.apache.logging.log4j2:type=1a6c5a9e,component=ContextSelector
2016-05-09 16:06:06,034 main DEBUG Registering MBean org.apache.logging.log4j2:type=1a6c5a9e,component=Loggers,name=
2016-05-09 16:06:06,036 main DEBUG Registering MBean org.apache.logging.log4j2:type=1a6c5a9e,component=Appenders,name=RollingRandomAccessFile
2016-05-09 16:06:06,041 main DEBUG Reconfiguration complete for context[name=1a6c5a9e] at URI /home/mrunal/repo/jigsaw/jigsaw/jigsaw-solution/jigsaw-matchmanager-business/target/classes/log4j2.xml (org.apache.logging.log4j.core.LoggerContext#732c2a62) with optional ClassLoader: null
2016-05-09 16:06:06,041 main DEBUG Shutdown hook enabled. Registering a new one.
16-05-09 16:06:06,043 main DEBUG LoggerContext[name=1a6c5a9e, org.apache.logging.log4j.core.LoggerContext#732c2a62] started OK.
Is there a dependency I am missing out or this some other problem? Please suggest possible things I can try for solving this problem. If you know a better solution to write logs in Logstash Json format you may suggest.
I suspect you are missing one of the Jackson dependencies.
You have jackson-core-asl, I think you need these three:
com.fasterxml.jackson.core:jackson-core:jar:2.6.3
com.fasterxml.jackson.core:jackson-databind:jar:2.6.3
com.fasterxml.jackson.core:jackson-annotations:jar:2.6.0
The ultimate source of truth for dependencies is the dependency tree of the Log4j 2 implementation module.
You may be able to get more details on the problem by setting <Configuration status="debug" ... in your configuration.

Log4j2 WebLookup

I'm using log4j2 (2.0.2) in a servlet 3.0 web application, running in Tomcat 8.0.12. I'm trying to use the weblookup to get the web app context path to use as part of the log file name. (We run the same war file under several different contexts using properties to configure it).
The log4j2.xml file includes
<RollingFile name="Web" fileName="/srv/dnsnet/logs/web-${web:contextPath}.logfile" filePattern="/srv/dnsnet/logs/web-${web:contextPath}-%d{yyyy-MM-dd}-%i.log.gz" append="true" immediateFlush="false">
<PatternLayout>
<Pattern>%d %-5p [%25.25t] %40.40c{3.} %15X{sysid} %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="8"/>
</RollingFile>
But the web:contextPath does not get resolved. I have got log4j-web-2.0.2.jar in my web app. I added some messages to the WebLookup class, and the problem is that the external context of the LoggerContext is null.
So I tried to see where the LoggerContext is created. The stack trace when the LoggerContext constructor is called is
at org.apache.logging.log4j.core.LoggerContext.<init>(LoggerContext.java:114)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:113)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:80)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:82)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:269)
at org.apache.logging.log4j.jcl.LogFactoryImpl$PrivateManager.getContext(LogFactoryImpl.java:108)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getLoggersMap(LogFactoryImpl.java:52)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:43)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:75)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
at org.apache.myfaces.webapp.AbstractMyFacesListener.<clinit>(AbstractMyFacesListener.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:433)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:151)
at org.apache.catalina.core.ApplicationContext.addListener(ApplicationContext.java:1231)
at org.apache.catalina.core.ApplicationContextFacade.addListener(ApplicationContextFacade.java:647)
at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:110)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5164)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1686)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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
But the ClassLoaderContextSelector always passes null for the external context. So it looks as though I'm missing something.
Can anyone suggest what I'm doing wrong, or missing? Do I have to specify a different ContextSelector?
You may have found a bug in log4j. I suspect it is the combination of Commons Logging and the WebLookup that does not work. Can you verify if this is the case (check if the WebLookup works if your application uses the log4j 2 API instead of Commons Logging) and file a bug report in the log4j2 Jira issue tracker?

Categories

Resources