anomalies running log4j v 2.2 on Tomcat

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

anomalies running log4j v 2.2 on Tomcat

COHEN, STEVEN M
I would be grateful for any input the members of this list can provide about the following situation.

We are running Tomcat 8.0.39, deploying on it a number of web applications using log4j2, the jars for which are packaged into the war files. These webapps are built in various environments.  One build environment (our "old" environment) cannot build with any JDK > 1.6.  Therefore it uses Log4j2 v.2.2 and embeds these jars into the war files it produces.  Tomcat itself is running JDK 1.8.

In catalina.out, we see the following error messages on startup whenever a webapp built in the "old" environment is loaded.
There are two anomalies:
1) the logger context names are numeric.  On those built with JDK1.8 and log4j 2.5+ they are derived from the name of the Webapp.
2) the ClassCastException errors.

In spite of the errors, the affected applications do seem to produce the logs that they have been configured to produce.

Are these errors a product of using such an old version of log4j2?  Would we expect them to disappear with a more modern version?  Do they indicate a serious problem?

Yes, I know we should be using a more modern JDK and Log4j, but inertia is a powerful force.  :-(

Thanks in advance for any information anyone is able to provide.

2017-04-17 20:24:34,035 DEBUG Starting LoggerContext[name=1728191654] from configuration at file:///usr/local/vtone/plat/ocsWeb/config/ocslog70Web.xml
2017-04-17 20:24:34,036 DEBUG Starting LoggerContext[name=1728191654, org.apache.logging.log4j.core.LoggerContext@207a11b8] with configuration XmlConfiguration[location=/usr/local/vtone/plat/ocsWeb/config/ocslog70Web.xml]...
2017-04-17 20:24:34,038 DEBUG Shutdown hook enabled. Registering a new one.
2017-04-17 20:24:34,040 DEBUG Starting configuration XmlConfiguration[location=/usr/local/vtone/plat/ocsWeb/config/ocslog70Web.xml]
2017-04-17 20:24:34,041 DEBUG PluginManager 'Core' found 98 plugins
2017-04-17 20:24:34,041 DEBUG PluginManager 'Level' found 0 plugins
2017-04-17 20:24:34,047 DEBUG PluginManager 'Lookup' found 14 plugins
2017-04-17 20:24:34,048 ERROR Unable to create Lookup for marker java.lang.ClassCastException: class org.apache.logging.log4j.core.lookup.MarkerLookup
        at java.lang.Class.asSubclass(Class.java:3404)
        at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:64)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:346)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:169)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:204)
        at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:109)
        at org.apache.logging.log4j.web.Log4jWebInitializerImpl.initializeNonJndi(Log4jWebInitializerImpl.java:157)
        at org.apache.logging.log4j.web.Log4jWebInitializerImpl.start(Log4jWebInitializerImpl.java:107)
        at org.apache.logging.log4j.web.Log4jServletContainerInitializer.onStartup(Log4jServletContainerInitializer.java:57)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
        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)

2017-04-17 20:24:34,051 ERROR Unable to create Lookup for main java.lang.ClassCastException: class org.apache.logging.log4j.core.lookup.MainMapLookup
        at java.lang.Class.asSubclass(Class.java:3404)
        at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:64)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:346)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:169)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:204)
        at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:109)
        at org.apache.logging.log4j.web.Log4jWebInitializerImpl.initializeNonJndi(Log4jWebInitializerImpl.java:157)
        at org.apache.logging.log4j.web.Log4jWebInitializerImpl.start(Log4jWebInitializerImpl.java:107)
        at org.apache.logging.log4j.web.Log4jServletContainerInitializer.onStartup(Log4jServletContainerInitializer.java:57)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: anomalies running log4j v 2.2 on Tomcat

Remko Popma-2
I can partially answer that. The LoggerContext name has changed a few times. I actually thought it's the other way around and the older versions of Log4j2 use a web app name-based LoggerContext name. It turned out that some web containers generate web context names that are multiple lines and contain line breaks. This created problems in Log4j2 JMX where the LoggerContext name is used in the ObjectName of all MBeans. Because of these JMX issues I changed the LoggerContext name to a unique short string (the hashcode of the LoggerContext object).

Are you sure it's the older version of Log4j2 that has numeric LoggerContext names? Anyway, other than JMX the LoggerContext name isn't used anywhere so it should not cause any issues.

Perhaps someone else can answer your question about the MarkerLookup ClassCastException.

Glad to hear Log4j2 is working well for you.
Remko

Sent from my iPhone

> On Apr 19, 2017, at 0:33, COHEN, STEVEN M <[hidden email]> wrote:
>
> I would be grateful for any input the members of this list can provide about the following situation.
>
> We are running Tomcat 8.0.39, deploying on it a number of web applications using log4j2, the jars for which are packaged into the war files. These webapps are built in various environments.  One build environment (our "old" environment) cannot build with any JDK > 1.6.  Therefore it uses Log4j2 v.2.2 and embeds these jars into the war files it produces.  Tomcat itself is running JDK 1.8.
>
> In catalina.out, we see the following error messages on startup whenever a webapp built in the "old" environment is loaded.
> There are two anomalies:
> 1) the logger context names are numeric.  On those built with JDK1.8 and log4j 2.5+ they are derived from the name of the Webapp.
> 2) the ClassCastException errors.
>
> In spite of the errors, the affected applications do seem to produce the logs that they have been configured to produce.
>
> Are these errors a product of using such an old version of log4j2?  Would we expect them to disappear with a more modern version?  Do they indicate a serious problem?
>
> Yes, I know we should be using a more modern JDK and Log4j, but inertia is a powerful force.  :-(
>
> Thanks in advance for any information anyone is able to provide.
>
> 2017-04-17 20:24:34,035 DEBUG Starting LoggerContext[name=1728191654] from configuration at file:///usr/local/vtone/plat/ocsWeb/config/ocslog70Web.xml
> 2017-04-17 20:24:34,036 DEBUG Starting LoggerContext[name=1728191654, org.apache.logging.log4j.core.LoggerContext@207a11b8] with configuration XmlConfiguration[location=/usr/local/vtone/plat/ocsWeb/config/ocslog70Web.xml]...
> 2017-04-17 20:24:34,038 DEBUG Shutdown hook enabled. Registering a new one.
> 2017-04-17 20:24:34,040 DEBUG Starting configuration XmlConfiguration[location=/usr/local/vtone/plat/ocsWeb/config/ocslog70Web.xml]
> 2017-04-17 20:24:34,041 DEBUG PluginManager 'Core' found 98 plugins
> 2017-04-17 20:24:34,041 DEBUG PluginManager 'Level' found 0 plugins
> 2017-04-17 20:24:34,047 DEBUG PluginManager 'Lookup' found 14 plugins
> 2017-04-17 20:24:34,048 ERROR Unable to create Lookup for marker java.lang.ClassCastException: class org.apache.logging.log4j.core.lookup.MarkerLookup
>        at java.lang.Class.asSubclass(Class.java:3404)
>        at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:64)
>        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:346)
>        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
>        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
>        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:169)
>        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:204)
>        at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:109)
>        at org.apache.logging.log4j.web.Log4jWebInitializerImpl.initializeNonJndi(Log4jWebInitializerImpl.java:157)
>        at org.apache.logging.log4j.web.Log4jWebInitializerImpl.start(Log4jWebInitializerImpl.java:107)
>        at org.apache.logging.log4j.web.Log4jServletContainerInitializer.onStartup(Log4jServletContainerInitializer.java:57)
>        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
>        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
>        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
>        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
>        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
>        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
>        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
>        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)
>
> 2017-04-17 20:24:34,051 ERROR Unable to create Lookup for main java.lang.ClassCastException: class org.apache.logging.log4j.core.lookup.MainMapLookup
>        at java.lang.Class.asSubclass(Class.java:3404)
>        at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:64)
>        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:346)
>        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
>        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
>        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:169)
>        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:204)
>        at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:109)
>        at org.apache.logging.log4j.web.Log4jWebInitializerImpl.initializeNonJndi(Log4jWebInitializerImpl.java:157)
>        at org.apache.logging.log4j.web.Log4jWebInitializerImpl.start(Log4jWebInitializerImpl.java:107)
>        at org.apache.logging.log4j.web.Log4jServletContainerInitializer.onStartup(Log4jServletContainerInitializer.java:57)
>        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
>        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
>        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...