Application Server integration in Tomcat

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Application Server integration in Tomcat

Paul
Hi,

Am trying to get Tomcat to log internal stuff through Log4j2, but
failing, no matter how I try.

I've followed the instruction at
https://logging.apache.org/log4j/2.x/log4j-appserver/index.html to no
avail.

I have a hard time understanding it, but maybe the problem is that the
Log4j2 code is executed in a different classLoader than the tomcat code:
I've enabled classloading debug output (-Xlog:class+load*=debug) and the
status logger (-Dlog4j2.debug) and I see that all Tomcat code is
executed by one classloader:

loader: [loader data: 0x000055f64b4557e0 of 'bootstrap']

whereas the Log4j2 code seems executed by a different classloader:

loader: [loader data: 0x00005559e1327de0 for instance a
'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x00000000e10c9c20}]

I have this in setenv.sh and setenv.sh is working properly otherwise:
CLASSPATH="$CATALINA_HOME/lib/*"

The $CATALINA_HOME/lib/ contains my log4j2-tomcat.properties and the
log4j-api and log4j-core jars (alongside slf4j-api.jar and
log4j-slf4j-impl.jar).  (all version 2.11.x)

I've also tried with the log4j-webon the classPath, didn't make a
difference. Tried the -Dlog4j.ignoreTCL=true options, no luck.

In the end, my main purpose it to log everything that happens in the JVM
through log4j2 to the console. I've also tried with
log4j-jul-2.11.1.jar, but couldn't get that going either: one of the
challenges I have is that I have a custom appender plugin that needs to
be loaded within the same classLoader hierarchy as where my (single)
webapp is running. In the end, I'll be running only 1 webapp, deployed
as a WAR in TOmcat and the whole thing is dockerized, so neither Tomcat
or the WAR are ever restarted/redeployed: if something needs to change,
we'll deploy a new container image

The output to the console of Tomcat is this:
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/lib/jvm/zulu11.2.3-jdk11.0.1-linux_musl_x64
Using CLASSPATH:
/usr/local/tomcat/lib/*:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

NOTE: Picked up JDK_JAVA_OPTIONS:
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
NOTE: Picked up JDK_JAVA_OPTIONS:
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
DEBUG StatusLogger Using ShutdownCallbackRegistry class
org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
INFO StatusLogger 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.
INFO StatusLogger 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.
DEBUG StatusLogger Took 0.143572 seconds to load 208 plugins from
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
DEBUG StatusLogger PluginManager 'Converter' found 44 plugins
DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
DEBUG StatusLogger Starting LoggerContext[name=799f7e29,
org.apache.logging.log4j.core.LoggerContext@ae13544]...
DEBUG StatusLogger Reconfiguration started for context[name=799f7e29] at
URI null (org.apache.logging.log4j.core.LoggerContext@ae13544) with
optional ClassLoader: null
INFO StatusLogger 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.
DEBUG StatusLogger PluginManager 'ConfigurationFactory' found 4 plugins
INFO StatusLogger 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.
INFO StatusLogger 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.
DEBUG StatusLogger Missing dependencies for Yaml support,
ConfigurationFactory
org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory is
inactive
INFO StatusLogger 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.
DEBUG StatusLogger Missing dependencies for Json support,
ConfigurationFactory
org.apache.logging.log4j.core.config.json.JsonConfigurationFactory is
inactive
INFO StatusLogger 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.
DEBUG StatusLogger Using configurationFactory
org.apache.logging.log4j.core.config.ConfigurationFactory$Factory@4e50c791
TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using
context class loader
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using
context class loader
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using
context class loader
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using
context class loader
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using
context class loader
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using
context class loader
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test.properties] using context
class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test.properties] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.properties] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.properties] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test.yml] using context class
loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test.yml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.yml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.yml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test.yaml] using context class
loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test.yaml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.yaml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.yaml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test.json] using context class
loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test.json] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.json] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.json] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test.jsn] using context class
loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test.jsn] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.jsn] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.jsn] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2-test.xml] using context class
loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2-test.xml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.xml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2-test.xml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using
context class loader
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using context
class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using context
class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2799f7e29.json] using context
class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2799f7e29.json] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.json] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.json] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using context
class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using context
class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2.properties] using context
class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2.properties] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.properties] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.properties] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2.yml] using context class
loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2.yml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.yml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.yml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2.yaml] using context class
loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2.yaml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.yaml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.yaml] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2.json] using context class
loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2.json] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.json] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.json] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2.jsn] using context class
loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2.jsn] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.jsn] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.jsn] using
ClassLoader.getSystemResource().
TRACE StatusLogger Trying to find [log4j2.xml] using context class
loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
TRACE StatusLogger Trying to find [log4j2.xml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.xml] using
jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
TRACE StatusLogger Trying to find [log4j2.xml] using
ClassLoader.getSystemResource().
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
INFO StatusLogger 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.


---
This email has been checked for viruses by AVG.
https://www.avg.com


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

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Remko Popma-2
Hi Paul,

Please try adding the log4j-web jar to the classpath:
> INFO StatusLogger 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.

Also, this user manual page may be useful: https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe this one: https://logging.apache.org/log4j/2.x/manual/logsep.html).

Remko.

(Shameless plug) Every java main() method deserves http://picocli.info

> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
>
> INFO StatusLogger 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.
Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Ralph Goers
In reply to this post by Paul
Were you using Tomcat 8.5 or greater? The instructions on the log4j-appserver page should work if you are using that version of Tomcat. Prior to that you will have to follow Tomcat’s instructions on how to replace the logging framework.

Ralph

> On Feb 19, 2019, at 9:03 AM, Paul <[hidden email]> wrote:
>
> Hi,
>
> Am trying to get Tomcat to log internal stuff through Log4j2, but failing, no matter how I try.
>
> I've followed the instruction at https://logging.apache.org/log4j/2.x/log4j-appserver/index.html to no avail.
>
> I have a hard time understanding it, but maybe the problem is that the Log4j2 code is executed in a different classLoader than the tomcat code: I've enabled classloading debug output (-Xlog:class+load*=debug) and the status logger (-Dlog4j2.debug) and I see that all Tomcat code is executed by one classloader:
>
> loader: [loader data: 0x000055f64b4557e0 of 'bootstrap']
>
> whereas the Log4j2 code seems executed by a different classloader:
>
> loader: [loader data: 0x00005559e1327de0 for instance a 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x00000000e10c9c20}]
>
> I have this in setenv.sh and setenv.sh is working properly otherwise:
> CLASSPATH="$CATALINA_HOME/lib/*"
>
> The $CATALINA_HOME/lib/ contains my log4j2-tomcat.properties and the log4j-api and log4j-core jars (alongside slf4j-api.jar and log4j-slf4j-impl.jar).  (all version 2.11.x)
>
> I've also tried with the log4j-webon the classPath, didn't make a difference. Tried the -Dlog4j.ignoreTCL=true options, no luck.
>
> In the end, my main purpose it to log everything that happens in the JVM through log4j2 to the console. I've also tried with log4j-jul-2.11.1.jar, but couldn't get that going either: one of the challenges I have is that I have a custom appender plugin that needs to be loaded within the same classLoader hierarchy as where my (single) webapp is running. In the end, I'll be running only 1 webapp, deployed as a WAR in TOmcat and the whole thing is dockerized, so neither Tomcat or the WAR are ever restarted/redeployed: if something needs to change, we'll deploy a new container image
>
> The output to the console of Tomcat is this:
> Using CATALINA_BASE:   /usr/local/tomcat
> Using CATALINA_HOME:   /usr/local/tomcat
> Using CATALINA_TMPDIR: /usr/local/tomcat/temp
> Using JRE_HOME: /usr/lib/jvm/zulu11.2.3-jdk11.0.1-linux_musl_x64
> Using CLASSPATH: /usr/local/tomcat/lib/*:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
> NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
> NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
> DEBUG StatusLogger Using ShutdownCallbackRegistry class org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
> INFO StatusLogger 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.
> INFO StatusLogger 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.
> DEBUG StatusLogger Took 0.143572 seconds to load 208 plugins from jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
> DEBUG StatusLogger PluginManager 'Converter' found 44 plugins
> DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
> DEBUG StatusLogger Starting LoggerContext[name=799f7e29, org.apache.logging.log4j.core.LoggerContext@ae13544]...
> DEBUG StatusLogger Reconfiguration started for context[name=799f7e29] at URI null (org.apache.logging.log4j.core.LoggerContext@ae13544) with optional ClassLoader: null
> INFO StatusLogger 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.
> DEBUG StatusLogger PluginManager 'ConfigurationFactory' found 4 plugins
> INFO StatusLogger 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.
> INFO StatusLogger 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.
> DEBUG StatusLogger Missing dependencies for Yaml support, ConfigurationFactory org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory is inactive
> INFO StatusLogger 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.
> DEBUG StatusLogger Missing dependencies for Json support, ConfigurationFactory org.apache.logging.log4j.core.config.json.JsonConfigurationFactory is inactive
> INFO StatusLogger 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.
> DEBUG StatusLogger Using configurationFactory org.apache.logging.log4j.core.config.ConfigurationFactory$Factory@4e50c791
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.properties] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.yml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.yaml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.json] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.jsn] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.xml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.properties] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.yml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.yaml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.json] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.jsn] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.xml] using ClassLoader.getSystemResource().
> 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
> INFO StatusLogger 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.
>
>
> ---
> This email has been checked for viruses by AVG.
> https://www.avg.com
>
>
> ---------------------------------------------------------------------
> 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]

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Paul
Yes, tomcat 9 on java 11

On Wed, Feb 20, 2019, 6:24 AM Ralph Goers <[hidden email] wrote:

> Were you using Tomcat 8.5 or greater? The instructions on the
> log4j-appserver page should work if you are using that version of Tomcat.
> Prior to that you will have to follow Tomcat’s instructions on how to
> replace the logging framework.
>
> Ralph
>
> > On Feb 19, 2019, at 9:03 AM, Paul <[hidden email]> wrote:
> >
> > Hi,
> >
> > Am trying to get Tomcat to log internal stuff through Log4j2, but
> failing, no matter how I try.
> >
> > I've followed the instruction at
> https://logging.apache.org/log4j/2.x/log4j-appserver/index.html to no
> avail.
> >
> > I have a hard time understanding it, but maybe the problem is that the
> Log4j2 code is executed in a different classLoader than the tomcat code:
> I've enabled classloading debug output (-Xlog:class+load*=debug) and the
> status logger (-Dlog4j2.debug) and I see that all Tomcat code is executed
> by one classloader:
> >
> > loader: [loader data: 0x000055f64b4557e0 of 'bootstrap']
> >
> > whereas the Log4j2 code seems executed by a different classloader:
> >
> > loader: [loader data: 0x00005559e1327de0 for instance a
> 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x00000000e10c9c20}]
> >
> > I have this in setenv.sh and setenv.sh is working properly otherwise:
> > CLASSPATH="$CATALINA_HOME/lib/*"
> >
> > The $CATALINA_HOME/lib/ contains my log4j2-tomcat.properties and the
> log4j-api and log4j-core jars (alongside slf4j-api.jar and
> log4j-slf4j-impl.jar).  (all version 2.11.x)
> >
> > I've also tried with the log4j-webon the classPath, didn't make a
> difference. Tried the -Dlog4j.ignoreTCL=true options, no luck.
> >
> > In the end, my main purpose it to log everything that happens in the JVM
> through log4j2 to the console. I've also tried with log4j-jul-2.11.1.jar,
> but couldn't get that going either: one of the challenges I have is that I
> have a custom appender plugin that needs to be loaded within the same
> classLoader hierarchy as where my (single) webapp is running. In the end,
> I'll be running only 1 webapp, deployed as a WAR in TOmcat and the whole
> thing is dockerized, so neither Tomcat or the WAR are ever
> restarted/redeployed: if something needs to change, we'll deploy a new
> container image
> >
> > The output to the console of Tomcat is this:
> > Using CATALINA_BASE:   /usr/local/tomcat
> > Using CATALINA_HOME:   /usr/local/tomcat
> > Using CATALINA_TMPDIR: /usr/local/tomcat/temp
> > Using JRE_HOME: /usr/lib/jvm/zulu11.2.3-jdk11.0.1-linux_musl_x64
> > Using CLASSPATH:
> /usr/local/tomcat/lib/*:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
>
> > NOTE: Picked up JDK_JAVA_OPTIONS:
> --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED
> --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
> > NOTE: Picked up JDK_JAVA_OPTIONS:
> --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED
> --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
> > DEBUG StatusLogger Using ShutdownCallbackRegistry class
> org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
> > INFO StatusLogger 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.
> > INFO StatusLogger 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.
> > DEBUG StatusLogger Took 0.143572 seconds to load 208 plugins from
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
> > DEBUG StatusLogger PluginManager 'Converter' found 44 plugins
> > DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
> > DEBUG StatusLogger Starting LoggerContext[name=799f7e29,
> org.apache.logging.log4j.core.LoggerContext@ae13544]...
> > DEBUG StatusLogger Reconfiguration started for context[name=799f7e29] at
> URI null (org.apache.logging.log4j.core.LoggerContext@ae13544) with
> optional ClassLoader: null
> > INFO StatusLogger 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.
> > DEBUG StatusLogger PluginManager 'ConfigurationFactory' found 4 plugins
> > INFO StatusLogger 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.
> > INFO StatusLogger 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.
> > DEBUG StatusLogger Missing dependencies for Yaml support,
> ConfigurationFactory
> org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory is
> inactive
> > INFO StatusLogger 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.
> > DEBUG StatusLogger Missing dependencies for Json support,
> ConfigurationFactory
> org.apache.logging.log4j.core.config.json.JsonConfigurationFactory is
> inactive
> > INFO StatusLogger 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.
> > DEBUG StatusLogger Using configurationFactory
> org.apache.logging.log4j.core.config.ConfigurationFactory$Factory@4e50c791
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using
> context class loader
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using
> context class loader
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using
> context class loader
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using
> context class loader
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using
> context class loader
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using
> context class loader
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test.properties] using context
> class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test.properties] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.properties] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.properties] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test.yml] using context class
> loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test.yml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.yml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.yml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test.yaml] using context class
> loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test.yaml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.yaml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.yaml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test.json] using context class
> loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test.json] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.json] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.json] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test.jsn] using context class
> loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test.jsn] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.jsn] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.jsn] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2-test.xml] using context class
> loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2-test.xml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.xml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2-test.xml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using
> context class loader
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using context
> class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using context
> class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2799f7e29.json] using context
> class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.json] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.json] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.json] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using context
> class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using context
> class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2.properties] using context
> class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2.properties] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.properties] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.properties] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2.yml] using context class
> loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2.yml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.yml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.yml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2.yaml] using context class
> loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2.yaml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.yaml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.yaml] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2.json] using context class
> loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2.json] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.json] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.json] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2.jsn] using context class
> loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2.jsn] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.jsn] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.jsn] using
> ClassLoader.getSystemResource().
> > TRACE StatusLogger Trying to find [log4j2.xml] using context class
> loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> > TRACE StatusLogger Trying to find [log4j2.xml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.xml] using
> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> > TRACE StatusLogger Trying to find [log4j2.xml] using
> ClassLoader.getSystemResource().
> > 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
> > INFO StatusLogger 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.
> >
> >
> > ---
> > This email has been checked for viruses by AVG.
> > https://www.avg.com
> >
> >
> > ---------------------------------------------------------------------
> > 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]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Paul
In reply to this post by Remko Popma-2
With log4j-web on the classmate the INFO statements you mentioned
disappear, but the problem of internal tomcat logging via log4j isn't
solved.

And I've went through but those links many times, tried everything I could
find there, but no avail

On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email] wrote:

> Hi Paul,
>
> Please try adding the log4j-web jar to the classpath:
> > INFO StatusLogger 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.
>
> Also, this user manual page may be useful:
> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe this
> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>
> Remko.
>
> (Shameless plug) Every java main() method deserves http://picocli.info
>
> > On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
> >
> > INFO StatusLogger 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.
>
Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Ralph Goers
Ok. I will try it myself with both of those and let you know, but it might take a couple of days.

Ralph

> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
>
> With log4j-web on the classmate the INFO statements you mentioned
> disappear, but the problem of internal tomcat logging via log4j isn't
> solved.
>
> And I've went through but those links many times, tried everything I could
> find there, but no avail
>
>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email] wrote:
>>
>> Hi Paul,
>>
>> Please try adding the log4j-web jar to the classpath:
>>> INFO StatusLogger 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.
>>
>> Also, this user manual page may be useful:
>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe this
>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>>
>> Remko.
>>
>> (Shameless plug) Every java main() method deserves http://picocli.info
>>
>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
>>>
>>> INFO StatusLogger 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.
>>



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

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Paul
Tnx

I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16,
log4j2 2.11.2, Java 1.8.0_162) but the exact same problem.

I've also looked at the docs on the Tomcat side: for Tomcat 9 the docs
on logging don't mention this mechanism to use log4j anymore. On the 8.0
documentation it is there, but talks about Log4j 1 and also details how
you need to replace the tomcat-juli(-adapters).jars, which I think is
not required anymore, see this case:
https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that case
seems to suggest that the way to replace tomcats internal logging is
through JUL....

So, I gave JUL another shot:

- with all the log4j-core/api/jul/ and a log4j2.properties on the
classpath set through  setenv.sh, I'm able to replace the internal
logging of Tomcat using Log4j2. So far so good.

- For the logging from the single webaap/WAR I'll ever deploy in this
tomcat instance, I have custom appenders that have static fields that
are accessed from within the deployed webapp and through the log4j2
appender interface methods. Hence, log4j2 and the webapp need to use the
same classloader (hierarchy), otherwise they'll be looking at teh same
class loaded through different classloaders, thus different instances of
the static field. I've got log4j2-web.jar and the jar containing my
custom appenders both in the WEB-INF/lib folder of my webapp + a
log4j2.properties in the WEB-INF folder, but then Log4J can't find the
custom appenders. If I put the jar with the custom appenders on the
classpath via Tomcat's setenv.sh, Log4J initializes properly, but the
WebApp and Log4j seem to use 2 different classloaders, thus I run into
the problem with multiple instances of the static field

Is there any setup I can use that works in this scenario?

Paul

On 20/02/2019 12:26, Apache wrote:

> Ok. I will try it myself with both of those and let you know, but it might take a couple of days.
>
> Ralph
>
>> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
>>
>> With log4j-web on the classmate the INFO statements you mentioned
>> disappear, but the problem of internal tomcat logging via log4j isn't
>> solved.
>>
>> And I've went through but those links many times, tried everything I could
>> find there, but no avail
>>
>>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email] wrote:
>>>
>>> Hi Paul,
>>>
>>> Please try adding the log4j-web jar to the classpath:
>>>> INFO StatusLogger 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.
>>>
>>> Also, this user manual page may be useful:
>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe this
>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>>>
>>> Remko.
>>>
>>> (Shameless plug) Every java main() method deserves http://picocli.info
>>>
>>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
>>>>
>>>> INFO StatusLogger 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.
>>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---
This email has been checked for viruses by AVG.
https://www.avg.com


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

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Ralph Goers
I am not really clear on what you are trying to achieve so this answer is making some guesses.

A typical tomcat deployment will have a boot class loader, the tomcat class loader and each web app will have its own class loader.  Tomcat’s logging has to happen using Tomcat’s class loader while the web app uses a combination of Tomcat’s and the Web Apps.

It sounds like you want:
To use Log4j for tomcat logging.
To use Log4j for application logging.
To incorporate your own appenders for application logging.

What I am not clear about is if you have any custom stuff you want to include for Tomcat logging. I am going to assume you don’t.

There are a couple of ways I would try to make this work. First, you have to remember that in Tomcat the WebApp class loader is searched first before delegating to the Tomcat class loader and that any classes in the Tomcat class loader won’t be able to directly access classes in the Web App class loader. If you place Log4j and your custom appenders in the tomcat class loader and do not include them in your web app then everything should work. However, if your custom appenders have dependencies on a bunch of custom code this can get pretty ugly as they would need to be in tomcat/lib as well.

Another way to deal with this would be to place the log4j jars in both tomcat/lib and in the web application’s WEB-INF/lib. Tomcat will initialize using the Log4j jars it finds in tomcat/lib. The web app should use the log4j jars from WEB-INF lib. In that case you will essentially have two separate log4j implementations, which is pretty much what you have to do to accomplish what it sounds like you want.  

Also, by default Log4j uses the ClassLoaderContextSelector. This insures that there are two LoggerContexts - one for tomcat and one for your web app. If you place everything in tomcat/lib you probably don’t want to use that ContextSelector. You probably would want to use the BasicContextSelector for that.

Ralph

> On Feb 22, 2019, at 9:27 AM, Paul <[hidden email]> wrote:
>
> Tnx
>
> I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16, log4j2 2.11.2, Java 1.8.0_162) but the exact same problem.
>
> I've also looked at the docs on the Tomcat side: for Tomcat 9 the docs on logging don't mention this mechanism to use log4j anymore. On the 8.0 documentation it is there, but talks about Log4j 1 and also details how you need to replace the tomcat-juli(-adapters).jars, which I think is not required anymore, see this case: https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that case seems to suggest that the way to replace tomcats internal logging is through JUL....
>
> So, I gave JUL another shot:
>
> - with all the log4j-core/api/jul/ and a log4j2.properties on the classpath set through  setenv.sh, I'm able to replace the internal logging of Tomcat using Log4j2. So far so good.
>
> - For the logging from the single webaap/WAR I'll ever deploy in this tomcat instance, I have custom appenders that have static fields that are accessed from within the deployed webapp and through the log4j2 appender interface methods. Hence, log4j2 and the webapp need to use the same classloader (hierarchy), otherwise they'll be looking at teh same class loaded through different classloaders, thus different instances of the static field. I've got log4j2-web.jar and the jar containing my custom appenders both in the WEB-INF/lib folder of my webapp + a log4j2.properties in the WEB-INF folder, but then Log4J can't find the custom appenders. If I put the jar with the custom appenders on the classpath via Tomcat's setenv.sh, Log4J initializes properly, but the WebApp and Log4j seem to use 2 different classloaders, thus I run into the problem with multiple instances of the static field
>
> Is there any setup I can use that works in this scenario?
>
> Paul
>
> On 20/02/2019 12:26, Apache wrote:
>> Ok. I will try it myself with both of those and let you know, but it might take a couple of days.
>>
>> Ralph
>>
>>> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
>>>
>>> With log4j-web on the classmate the INFO statements you mentioned
>>> disappear, but the problem of internal tomcat logging via log4j isn't
>>> solved.
>>>
>>> And I've went through but those links many times, tried everything I could
>>> find there, but no avail
>>>
>>>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email] wrote:
>>>>
>>>> Hi Paul,
>>>>
>>>> Please try adding the log4j-web jar to the classpath:
>>>>> INFO StatusLogger 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.
>>>>
>>>> Also, this user manual page may be useful:
>>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe this
>>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>>>>
>>>> Remko.
>>>>
>>>> (Shameless plug) Every java main() method deserves http://picocli.info
>>>>
>>>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
>>>>>
>>>>> INFO StatusLogger 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.
>>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---
> This email has been checked for viruses by AVG.
> https://www.avg.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Paul
Hi Ralph,

See in between the lines.

Curious to hear what your take is on the classloader usage which is what
is causing my issues.

Paul

On 22/02/2019 18:43, Ralph Goers wrote:
> I am not really clear on what you are trying to achieve so this answer is making some guesses.
>
> A typical tomcat deployment will have a boot class loader, the tomcat class loader and each web app will have its own class loader.  Tomcat’s logging has to happen using Tomcat’s class loader while the web app uses a combination of Tomcat’s and the Web Apps.
>
> It sounds like you want:
> To use Log4j for tomcat logging.
> To use Log4j for application logging.
> To incorporate your own appenders for application logging.
Correct
>
> What I am not clear about is if you have any custom stuff you want to include for Tomcat logging. I am going to assume you don’t.
Correct assumption, I don't need anything custom for Tomcat logging
>
> There are a couple of ways I would try to make this work. First, you have to remember that in Tomcat the WebApp class loader is searched first before delegating to the Tomcat class loader and that any classes in the Tomcat class loader won’t be able to directly access classes in the Web App class loader. If you place Log4j and your custom appenders in the tomcat class loader and do not include them in your web app then everything should work. However, if your custom appenders have dependencies on a bunch of custom code this can get pretty ugly as they would need to be in tomcat/lib as well.

The custom appenders are standalone, they just have a public static
field that is accessed by code in my webapp.

I tried doing as you described, but to no avail. It seems like the log4j
stuff isn't loaded using the bootstrap/system or common classloader, but
through the Java system classloader. What I don't understand is why the
log4j stuff seems loaded by the Java system classloader and not the
Tomcat classloaders... To my understanding: if any of the
bootstrap/system or common classloaders of Tomcat would be used, all
would be good, as those are all in the webapp classloader hierarchy,
correct?

>
> Another way to deal with this would be to place the log4j jars in both tomcat/lib and in the web application’s WEB-INF/lib. Tomcat will initialize using the Log4j jars it finds in tomcat/lib. The web app should use the log4j jars from WEB-INF lib. In that case you will essentially have two separate log4j implementations, which is pretty much what you have to do to accomplish what it sounds like you want.
I haven't tried rolling two full log4j implementations, find that a bit
of waist of resources (@runtime, but also deployment-wise: we'll have
many containers running using this setup)

>
> Also, by default Log4j uses the ClassLoaderContextSelector. This insures that there are two LoggerContexts - one for tomcat and one for your web app. If you place everything in tomcat/lib you probably don’t want to use that ContextSelector. You probably would want to use the BasicContextSelector for that.
>
> Ralph
>
>> On Feb 22, 2019, at 9:27 AM, Paul <[hidden email]> wrote:
>>
>> Tnx
>>
>> I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16, log4j2 2.11.2, Java 1.8.0_162) but the exact same problem.
>>
>> I've also looked at the docs on the Tomcat side: for Tomcat 9 the docs on logging don't mention this mechanism to use log4j anymore. On the 8.0 documentation it is there, but talks about Log4j 1 and also details how you need to replace the tomcat-juli(-adapters).jars, which I think is not required anymore, see this case: https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that case seems to suggest that the way to replace tomcats internal logging is through JUL....
>>
>> So, I gave JUL another shot:
>>
>> - with all the log4j-core/api/jul/ and a log4j2.properties on the classpath set through  setenv.sh, I'm able to replace the internal logging of Tomcat using Log4j2. So far so good.
>>
>> - For the logging from the single webaap/WAR I'll ever deploy in this tomcat instance, I have custom appenders that have static fields that are accessed from within the deployed webapp and through the log4j2 appender interface methods. Hence, log4j2 and the webapp need to use the same classloader (hierarchy), otherwise they'll be looking at teh same class loaded through different classloaders, thus different instances of the static field. I've got log4j2-web.jar and the jar containing my custom appenders both in the WEB-INF/lib folder of my webapp + a log4j2.properties in the WEB-INF folder, but then Log4J can't find the custom appenders. If I put the jar with the custom appenders on the classpath via Tomcat's setenv.sh, Log4J initializes properly, but the WebApp and Log4j seem to use 2 different classloaders, thus I run into the problem with multiple instances of the static field
>>
>> Is there any setup I can use that works in this scenario?
>>
>> Paul
>>
>> On 20/02/2019 12:26, Apache wrote:
>>> Ok. I will try it myself with both of those and let you know, but it might take a couple of days.
>>>
>>> Ralph
>>>
>>>> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
>>>>
>>>> With log4j-web on the classmate the INFO statements you mentioned
>>>> disappear, but the problem of internal tomcat logging via log4j isn't
>>>> solved.
>>>>
>>>> And I've went through but those links many times, tried everything I could
>>>> find there, but no avail
>>>>
>>>>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email] wrote:
>>>>>
>>>>> Hi Paul,
>>>>>
>>>>> Please try adding the log4j-web jar to the classpath:
>>>>>> INFO StatusLogger 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.
>>>>>
>>>>> Also, this user manual page may be useful:
>>>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe this
>>>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>>>>>
>>>>> Remko.
>>>>>
>>>>> (Shameless plug) Every java main() method deserves http://picocli.info
>>>>>
>>>>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
>>>>>>
>>>>>> INFO StatusLogger 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.
>>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>> ---
>> This email has been checked for viruses by AVG.
>> https://www.avg.com
>>
>>
>> ---------------------------------------------------------------------
>> 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]

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Ralph Goers
Tomcat’s class loader will be a parent of the web app class loader. That means the log4j-related classes placed in the tomcat class loader won’t be able to access anything in your web-app class loader. But your application should have no problem accessing them in tomcat’s class loader provided you don’t also have them in your web-app.  That said, I haven’t looked at Tomcat 9 yet. It is possible that they have an additional class loader that is not in the parent hierarchy of the web-app class loader. If that is the case your web app wouldn’t be able to access it. But then again, it wouldn’t find Log4j either.

What error do you get when you try to access the static fields?

Ralph

> On Feb 22, 2019, at 11:13 AM, Paul <[hidden email]> wrote:
>
> Hi Ralph,
>
> See in between the lines.
>
> Curious to hear what your take is on the classloader usage which is what is causing my issues.
>
> Paul
>
> On 22/02/2019 18:43, Ralph Goers wrote:
>> I am not really clear on what you are trying to achieve so this answer is making some guesses.
>>
>> A typical tomcat deployment will have a boot class loader, the tomcat class loader and each web app will have its own class loader.  Tomcat’s logging has to happen using Tomcat’s class loader while the web app uses a combination of Tomcat’s and the Web Apps.
>>
>> It sounds like you want:
>> To use Log4j for tomcat logging.
>> To use Log4j for application logging.
>> To incorporate your own appenders for application logging.
> Correct
>>
>> What I am not clear about is if you have any custom stuff you want to include for Tomcat logging. I am going to assume you don’t.
> Correct assumption, I don't need anything custom for Tomcat logging
>>
>> There are a couple of ways I would try to make this work. First, you have to remember that in Tomcat the WebApp class loader is searched first before delegating to the Tomcat class loader and that any classes in the Tomcat class loader won’t be able to directly access classes in the Web App class loader. If you place Log4j and your custom appenders in the tomcat class loader and do not include them in your web app then everything should work. However, if your custom appenders have dependencies on a bunch of custom code this can get pretty ugly as they would need to be in tomcat/lib as well.
>
> The custom appenders are standalone, they just have a public static field that is accessed by code in my webapp.
>
> I tried doing as you described, but to no avail. It seems like the log4j stuff isn't loaded using the bootstrap/system or common classloader, but through the Java system classloader. What I don't understand is why the log4j stuff seems loaded by the Java system classloader and not the Tomcat classloaders... To my understanding: if any of the bootstrap/system or common classloaders of Tomcat would be used, all would be good, as those are all in the webapp classloader hierarchy, correct?
>
>>
>> Another way to deal with this would be to place the log4j jars in both tomcat/lib and in the web application’s WEB-INF/lib. Tomcat will initialize using the Log4j jars it finds in tomcat/lib. The web app should use the log4j jars from WEB-INF lib. In that case you will essentially have two separate log4j implementations, which is pretty much what you have to do to accomplish what it sounds like you want.
> I haven't tried rolling two full log4j implementations, find that a bit of waist of resources (@runtime, but also deployment-wise: we'll have many containers running using this setup)
>>
>> Also, by default Log4j uses the ClassLoaderContextSelector. This insures that there are two LoggerContexts - one for tomcat and one for your web app. If you place everything in tomcat/lib you probably don’t want to use that ContextSelector. You probably would want to use the BasicContextSelector for that.
>>
>> Ralph
>>
>>> On Feb 22, 2019, at 9:27 AM, Paul <[hidden email]> wrote:
>>>
>>> Tnx
>>>
>>> I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16, log4j2 2.11.2, Java 1.8.0_162) but the exact same problem.
>>>
>>> I've also looked at the docs on the Tomcat side: for Tomcat 9 the docs on logging don't mention this mechanism to use log4j anymore. On the 8.0 documentation it is there, but talks about Log4j 1 and also details how you need to replace the tomcat-juli(-adapters).jars, which I think is not required anymore, see this case: https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that case seems to suggest that the way to replace tomcats internal logging is through JUL....
>>>
>>> So, I gave JUL another shot:
>>>
>>> - with all the log4j-core/api/jul/ and a log4j2.properties on the classpath set through  setenv.sh, I'm able to replace the internal logging of Tomcat using Log4j2. So far so good.
>>>
>>> - For the logging from the single webaap/WAR I'll ever deploy in this tomcat instance, I have custom appenders that have static fields that are accessed from within the deployed webapp and through the log4j2 appender interface methods. Hence, log4j2 and the webapp need to use the same classloader (hierarchy), otherwise they'll be looking at teh same class loaded through different classloaders, thus different instances of the static field. I've got log4j2-web.jar and the jar containing my custom appenders both in the WEB-INF/lib folder of my webapp + a log4j2.properties in the WEB-INF folder, but then Log4J can't find the custom appenders. If I put the jar with the custom appenders on the classpath via Tomcat's setenv.sh, Log4J initializes properly, but the WebApp and Log4j seem to use 2 different classloaders, thus I run into the problem with multiple instances of the static field
>>>
>>> Is there any setup I can use that works in this scenario?
>>>
>>> Paul
>>>
>>> On 20/02/2019 12:26, Apache wrote:
>>>> Ok. I will try it myself with both of those and let you know, but it might take a couple of days.
>>>>
>>>> Ralph
>>>>
>>>>> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
>>>>>
>>>>> With log4j-web on the classmate the INFO statements you mentioned
>>>>> disappear, but the problem of internal tomcat logging via log4j isn't
>>>>> solved.
>>>>>
>>>>> And I've went through but those links many times, tried everything I could
>>>>> find there, but no avail
>>>>>
>>>>>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email] wrote:
>>>>>>
>>>>>> Hi Paul,
>>>>>>
>>>>>> Please try adding the log4j-web jar to the classpath:
>>>>>>> INFO StatusLogger 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.
>>>>>>
>>>>>> Also, this user manual page may be useful:
>>>>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe this
>>>>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>>>>>>
>>>>>> Remko.
>>>>>>
>>>>>> (Shameless plug) Every java main() method deserves http://picocli.info
>>>>>>
>>>>>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
>>>>>>>
>>>>>>> INFO StatusLogger 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.
>>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>> ---
>>> This email has been checked for viruses by AVG.
>>> https://www.avg.com
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email] <mailto:[hidden email]>
> For additional commands, e-mail: [hidden email] <mailto:[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Ralph Goers
FWIW, Looking at the Tomcat 9.0 code I see the same ServiceLoader code as in Tomcat 8.5, so the log4j-appserver code should still work.

Ralph

> On Feb 22, 2019, at 11:27 AM, Ralph Goers <[hidden email]> wrote:
>
> Tomcat’s class loader will be a parent of the web app class loader. That means the log4j-related classes placed in the tomcat class loader won’t be able to access anything in your web-app class loader. But your application should have no problem accessing them in tomcat’s class loader provided you don’t also have them in your web-app.  That said, I haven’t looked at Tomcat 9 yet. It is possible that they have an additional class loader that is not in the parent hierarchy of the web-app class loader. If that is the case your web app wouldn’t be able to access it. But then again, it wouldn’t find Log4j either.
>
> What error do you get when you try to access the static fields?
>
> Ralph
>
>> On Feb 22, 2019, at 11:13 AM, Paul <[hidden email]> wrote:
>>
>> Hi Ralph,
>>
>> See in between the lines.
>>
>> Curious to hear what your take is on the classloader usage which is what is causing my issues.
>>
>> Paul
>>
>> On 22/02/2019 18:43, Ralph Goers wrote:
>>> I am not really clear on what you are trying to achieve so this answer is making some guesses.
>>>
>>> A typical tomcat deployment will have a boot class loader, the tomcat class loader and each web app will have its own class loader.  Tomcat’s logging has to happen using Tomcat’s class loader while the web app uses a combination of Tomcat’s and the Web Apps.
>>>
>>> It sounds like you want:
>>> To use Log4j for tomcat logging.
>>> To use Log4j for application logging.
>>> To incorporate your own appenders for application logging.
>> Correct
>>>
>>> What I am not clear about is if you have any custom stuff you want to include for Tomcat logging. I am going to assume you don’t.
>> Correct assumption, I don't need anything custom for Tomcat logging
>>>
>>> There are a couple of ways I would try to make this work. First, you have to remember that in Tomcat the WebApp class loader is searched first before delegating to the Tomcat class loader and that any classes in the Tomcat class loader won’t be able to directly access classes in the Web App class loader. If you place Log4j and your custom appenders in the tomcat class loader and do not include them in your web app then everything should work. However, if your custom appenders have dependencies on a bunch of custom code this can get pretty ugly as they would need to be in tomcat/lib as well.
>>
>> The custom appenders are standalone, they just have a public static field that is accessed by code in my webapp.
>>
>> I tried doing as you described, but to no avail. It seems like the log4j stuff isn't loaded using the bootstrap/system or common classloader, but through the Java system classloader. What I don't understand is why the log4j stuff seems loaded by the Java system classloader and not the Tomcat classloaders... To my understanding: if any of the bootstrap/system or common classloaders of Tomcat would be used, all would be good, as those are all in the webapp classloader hierarchy, correct?
>>
>>>
>>> Another way to deal with this would be to place the log4j jars in both tomcat/lib and in the web application’s WEB-INF/lib. Tomcat will initialize using the Log4j jars it finds in tomcat/lib. The web app should use the log4j jars from WEB-INF lib. In that case you will essentially have two separate log4j implementations, which is pretty much what you have to do to accomplish what it sounds like you want.
>> I haven't tried rolling two full log4j implementations, find that a bit of waist of resources (@runtime, but also deployment-wise: we'll have many containers running using this setup)
>>>
>>> Also, by default Log4j uses the ClassLoaderContextSelector. This insures that there are two LoggerContexts - one for tomcat and one for your web app. If you place everything in tomcat/lib you probably don’t want to use that ContextSelector. You probably would want to use the BasicContextSelector for that.
>>>
>>> Ralph
>>>
>>>> On Feb 22, 2019, at 9:27 AM, Paul <[hidden email]> wrote:
>>>>
>>>> Tnx
>>>>
>>>> I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16, log4j2 2.11.2, Java 1.8.0_162) but the exact same problem.
>>>>
>>>> I've also looked at the docs on the Tomcat side: for Tomcat 9 the docs on logging don't mention this mechanism to use log4j anymore. On the 8.0 documentation it is there, but talks about Log4j 1 and also details how you need to replace the tomcat-juli(-adapters).jars, which I think is not required anymore, see this case: https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that case seems to suggest that the way to replace tomcats internal logging is through JUL....
>>>>
>>>> So, I gave JUL another shot:
>>>>
>>>> - with all the log4j-core/api/jul/ and a log4j2.properties on the classpath set through  setenv.sh, I'm able to replace the internal logging of Tomcat using Log4j2. So far so good.
>>>>
>>>> - For the logging from the single webaap/WAR I'll ever deploy in this tomcat instance, I have custom appenders that have static fields that are accessed from within the deployed webapp and through the log4j2 appender interface methods. Hence, log4j2 and the webapp need to use the same classloader (hierarchy), otherwise they'll be looking at teh same class loaded through different classloaders, thus different instances of the static field. I've got log4j2-web.jar and the jar containing my custom appenders both in the WEB-INF/lib folder of my webapp + a log4j2.properties in the WEB-INF folder, but then Log4J can't find the custom appenders. If I put the jar with the custom appenders on the classpath via Tomcat's setenv.sh, Log4J initializes properly, but the WebApp and Log4j seem to use 2 different classloaders, thus I run into the problem with multiple instances of the static field
>>>>
>>>> Is there any setup I can use that works in this scenario?
>>>>
>>>> Paul
>>>>
>>>> On 20/02/2019 12:26, Apache wrote:
>>>>> Ok. I will try it myself with both of those and let you know, but it might take a couple of days.
>>>>>
>>>>> Ralph
>>>>>
>>>>>> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
>>>>>>
>>>>>> With log4j-web on the classmate the INFO statements you mentioned
>>>>>> disappear, but the problem of internal tomcat logging via log4j isn't
>>>>>> solved.
>>>>>>
>>>>>> And I've went through but those links many times, tried everything I could
>>>>>> find there, but no avail
>>>>>>
>>>>>>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email] wrote:
>>>>>>>
>>>>>>> Hi Paul,
>>>>>>>
>>>>>>> Please try adding the log4j-web jar to the classpath:
>>>>>>>> INFO StatusLogger 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.
>>>>>>>
>>>>>>> Also, this user manual page may be useful:
>>>>>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe this
>>>>>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>>>>>>>
>>>>>>> Remko.
>>>>>>>
>>>>>>> (Shameless plug) Every java main() method deserves http://picocli.info
>>>>>>>
>>>>>>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> INFO StatusLogger 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.
>>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>> ---
>>>> This email has been checked for viruses by AVG.
>>>> https://www.avg.com
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email] <mailto:[hidden email]>
>> For additional commands, e-mail: [hidden email] <mailto:[hidden email]>



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

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Ralph Goers
Another possibility -

Take a look at “Advanced Configuration” at http://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html <http://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html>. If you define a server loader and place the Log4j jars there then Tomcat should use Log4j for logging and the applications will be completely unaware. You can then package your war “normally” and it should function completely independently of tomcat’s logging. I haven’t tried this myself though, so you will have to wait for me to be able to try it out before I can tell you whether it actually works.

Ralph

> On Feb 22, 2019, at 11:45 AM, Ralph Goers <[hidden email]> wrote:
>
> FWIW, Looking at the Tomcat 9.0 code I see the same ServiceLoader code as in Tomcat 8.5, so the log4j-appserver code should still work.
>
> Ralph
>
>> On Feb 22, 2019, at 11:27 AM, Ralph Goers <[hidden email] <mailto:[hidden email]>> wrote:
>>
>> Tomcat’s class loader will be a parent of the web app class loader. That means the log4j-related classes placed in the tomcat class loader won’t be able to access anything in your web-app class loader. But your application should have no problem accessing them in tomcat’s class loader provided you don’t also have them in your web-app.  That said, I haven’t looked at Tomcat 9 yet. It is possible that they have an additional class loader that is not in the parent hierarchy of the web-app class loader. If that is the case your web app wouldn’t be able to access it. But then again, it wouldn’t find Log4j either.
>>
>> What error do you get when you try to access the static fields?
>>
>> Ralph
>>
>>> On Feb 22, 2019, at 11:13 AM, Paul <[hidden email]> wrote:
>>>
>>> Hi Ralph,
>>>
>>> See in between the lines.
>>>
>>> Curious to hear what your take is on the classloader usage which is what is causing my issues.
>>>
>>> Paul
>>>
>>> On 22/02/2019 18:43, Ralph Goers wrote:
>>>> I am not really clear on what you are trying to achieve so this answer is making some guesses.
>>>>
>>>> A typical tomcat deployment will have a boot class loader, the tomcat class loader and each web app will have its own class loader.  Tomcat’s logging has to happen using Tomcat’s class loader while the web app uses a combination of Tomcat’s and the Web Apps.
>>>>
>>>> It sounds like you want:
>>>> To use Log4j for tomcat logging.
>>>> To use Log4j for application logging.
>>>> To incorporate your own appenders for application logging.
>>> Correct
>>>>
>>>> What I am not clear about is if you have any custom stuff you want to include for Tomcat logging. I am going to assume you don’t.
>>> Correct assumption, I don't need anything custom for Tomcat logging
>>>>
>>>> There are a couple of ways I would try to make this work. First, you have to remember that in Tomcat the WebApp class loader is searched first before delegating to the Tomcat class loader and that any classes in the Tomcat class loader won’t be able to directly access classes in the Web App class loader. If you place Log4j and your custom appenders in the tomcat class loader and do not include them in your web app then everything should work. However, if your custom appenders have dependencies on a bunch of custom code this can get pretty ugly as they would need to be in tomcat/lib as well.
>>>
>>> The custom appenders are standalone, they just have a public static field that is accessed by code in my webapp.
>>>
>>> I tried doing as you described, but to no avail. It seems like the log4j stuff isn't loaded using the bootstrap/system or common classloader, but through the Java system classloader. What I don't understand is why the log4j stuff seems loaded by the Java system classloader and not the Tomcat classloaders... To my understanding: if any of the bootstrap/system or common classloaders of Tomcat would be used, all would be good, as those are all in the webapp classloader hierarchy, correct?
>>>
>>>>
>>>> Another way to deal with this would be to place the log4j jars in both tomcat/lib and in the web application’s WEB-INF/lib. Tomcat will initialize using the Log4j jars it finds in tomcat/lib. The web app should use the log4j jars from WEB-INF lib. In that case you will essentially have two separate log4j implementations, which is pretty much what you have to do to accomplish what it sounds like you want.
>>> I haven't tried rolling two full log4j implementations, find that a bit of waist of resources (@runtime, but also deployment-wise: we'll have many containers running using this setup)
>>>>
>>>> Also, by default Log4j uses the ClassLoaderContextSelector. This insures that there are two LoggerContexts - one for tomcat and one for your web app. If you place everything in tomcat/lib you probably don’t want to use that ContextSelector. You probably would want to use the BasicContextSelector for that.
>>>>
>>>> Ralph
>>>>
>>>>> On Feb 22, 2019, at 9:27 AM, Paul <[hidden email]> wrote:
>>>>>
>>>>> Tnx
>>>>>
>>>>> I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16, log4j2 2.11.2, Java 1.8.0_162) but the exact same problem.
>>>>>
>>>>> I've also looked at the docs on the Tomcat side: for Tomcat 9 the docs on logging don't mention this mechanism to use log4j anymore. On the 8.0 documentation it is there, but talks about Log4j 1 and also details how you need to replace the tomcat-juli(-adapters).jars, which I think is not required anymore, see this case: https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that case seems to suggest that the way to replace tomcats internal logging is through JUL....
>>>>>
>>>>> So, I gave JUL another shot:
>>>>>
>>>>> - with all the log4j-core/api/jul/ and a log4j2.properties on the classpath set through  setenv.sh, I'm able to replace the internal logging of Tomcat using Log4j2. So far so good.
>>>>>
>>>>> - For the logging from the single webaap/WAR I'll ever deploy in this tomcat instance, I have custom appenders that have static fields that are accessed from within the deployed webapp and through the log4j2 appender interface methods. Hence, log4j2 and the webapp need to use the same classloader (hierarchy), otherwise they'll be looking at teh same class loaded through different classloaders, thus different instances of the static field. I've got log4j2-web.jar and the jar containing my custom appenders both in the WEB-INF/lib folder of my webapp + a log4j2.properties in the WEB-INF folder, but then Log4J can't find the custom appenders. If I put the jar with the custom appenders on the classpath via Tomcat's setenv.sh, Log4J initializes properly, but the WebApp and Log4j seem to use 2 different classloaders, thus I run into the problem with multiple instances of the static field
>>>>>
>>>>> Is there any setup I can use that works in this scenario?
>>>>>
>>>>> Paul
>>>>>
>>>>> On 20/02/2019 12:26, Apache wrote:
>>>>>> Ok. I will try it myself with both of those and let you know, but it might take a couple of days.
>>>>>>
>>>>>> Ralph
>>>>>>
>>>>>>> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
>>>>>>>
>>>>>>> With log4j-web on the classmate the INFO statements you mentioned
>>>>>>> disappear, but the problem of internal tomcat logging via log4j isn't
>>>>>>> solved.
>>>>>>>
>>>>>>> And I've went through but those links many times, tried everything I could
>>>>>>> find there, but no avail
>>>>>>>
>>>>>>>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email] wrote:
>>>>>>>>
>>>>>>>> Hi Paul,
>>>>>>>>
>>>>>>>> Please try adding the log4j-web jar to the classpath:
>>>>>>>>> INFO StatusLogger 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.
>>>>>>>>
>>>>>>>> Also, this user manual page may be useful:
>>>>>>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe this
>>>>>>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>>>>>>>>
>>>>>>>> Remko.
>>>>>>>>
>>>>>>>> (Shameless plug) Every java main() method deserves http://picocli.info
>>>>>>>>
>>>>>>>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
>>>>>>>>>
>>>>>>>>> INFO StatusLogger 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.
>>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>
>>>>> ---
>>>>> This email has been checked for viruses by AVG.
>>>>> https://www.avg.com
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>
>>> For additional commands, e-mail: [hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email] <mailto:[hidden email]>
> For additional commands, e-mail: [hidden email] <mailto:[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Paul
In reply to this post by Ralph Goers
The 'error' I get is that the static field on my custom appender class is
null when accessed from my webapp, long after log4j is initialized, while
the appender constructor that log4j called sets is value.

And the access to that static field happens long after log4j is initialized.

So my conclusion is that the appender class is loaded by multiple
classloader

Maybe it's using the java system classloader cause I'm using log4j-jul (as
log4j-appserver doesn't work)?

Paul

On Fri, Feb 22, 2019, 7:27 PM Ralph Goers <[hidden email]>
wrote:

> Tomcat’s class loader will be a parent of the web app class loader. That
> means the log4j-related classes placed in the tomcat class loader won’t be
> able to access anything in your web-app class loader. But your application
> should have no problem accessing them in tomcat’s class loader provided you
> don’t also have them in your web-app.  That said, I haven’t looked at
> Tomcat 9 yet. It is possible that they have an additional class loader that
> is not in the parent hierarchy of the web-app class loader. If that is the
> case your web app wouldn’t be able to access it. But then again, it
> wouldn’t find Log4j either.
>
> What error do you get when you try to access the static fields?
>
> Ralph
>
> > On Feb 22, 2019, at 11:13 AM, Paul <[hidden email]> wrote:
> >
> > Hi Ralph,
> >
> > See in between the lines.
> >
> > Curious to hear what your take is on the classloader usage which is what
> is causing my issues.
> >
> > Paul
> >
> > On 22/02/2019 18:43, Ralph Goers wrote:
> >> I am not really clear on what you are trying to achieve so this answer
> is making some guesses.
> >>
> >> A typical tomcat deployment will have a boot class loader, the tomcat
> class loader and each web app will have its own class loader.  Tomcat’s
> logging has to happen using Tomcat’s class loader while the web app uses a
> combination of Tomcat’s and the Web Apps.
> >>
> >> It sounds like you want:
> >> To use Log4j for tomcat logging.
> >> To use Log4j for application logging.
> >> To incorporate your own appenders for application logging.
> > Correct
> >>
> >> What I am not clear about is if you have any custom stuff you want to
> include for Tomcat logging. I am going to assume you don’t.
> > Correct assumption, I don't need anything custom for Tomcat logging
> >>
> >> There are a couple of ways I would try to make this work. First, you
> have to remember that in Tomcat the WebApp class loader is searched first
> before delegating to the Tomcat class loader and that any classes in the
> Tomcat class loader won’t be able to directly access classes in the Web App
> class loader. If you place Log4j and your custom appenders in the tomcat
> class loader and do not include them in your web app then everything should
> work. However, if your custom appenders have dependencies on a bunch of
> custom code this can get pretty ugly as they would need to be in tomcat/lib
> as well.
> >
> > The custom appenders are standalone, they just have a public static
> field that is accessed by code in my webapp.
> >
> > I tried doing as you described, but to no avail. It seems like the log4j
> stuff isn't loaded using the bootstrap/system or common classloader, but
> through the Java system classloader. What I don't understand is why the
> log4j stuff seems loaded by the Java system classloader and not the Tomcat
> classloaders... To my understanding: if any of the bootstrap/system or
> common classloaders of Tomcat would be used, all would be good, as those
> are all in the webapp classloader hierarchy, correct?
> >
> >>
> >> Another way to deal with this would be to place the log4j jars in both
> tomcat/lib and in the web application’s WEB-INF/lib. Tomcat will initialize
> using the Log4j jars it finds in tomcat/lib. The web app should use the
> log4j jars from WEB-INF lib. In that case you will essentially have two
> separate log4j implementations, which is pretty much what you have to do to
> accomplish what it sounds like you want.
> > I haven't tried rolling two full log4j implementations, find that a bit
> of waist of resources (@runtime, but also deployment-wise: we'll have many
> containers running using this setup)
> >>
> >> Also, by default Log4j uses the ClassLoaderContextSelector. This
> insures that there are two LoggerContexts - one for tomcat and one for your
> web app. If you place everything in tomcat/lib you probably don’t want to
> use that ContextSelector. You probably would want to use the
> BasicContextSelector for that.
> >>
> >> Ralph
> >>
> >>> On Feb 22, 2019, at 9:27 AM, Paul <[hidden email]> wrote:
> >>>
> >>> Tnx
> >>>
> >>> I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16,
> log4j2 2.11.2, Java 1.8.0_162) but the exact same problem.
> >>>
> >>> I've also looked at the docs on the Tomcat side: for Tomcat 9 the docs
> on logging don't mention this mechanism to use log4j anymore. On the 8.0
> documentation it is there, but talks about Log4j 1 and also details how you
> need to replace the tomcat-juli(-adapters).jars, which I think is not
> required anymore, see this case:
> https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that case
> seems to suggest that the way to replace tomcats internal logging is
> through JUL....
> >>>
> >>> So, I gave JUL another shot:
> >>>
> >>> - with all the log4j-core/api/jul/ and a log4j2.properties on the
> classpath set through  setenv.sh, I'm able to replace the internal logging
> of Tomcat using Log4j2. So far so good.
> >>>
> >>> - For the logging from the single webaap/WAR I'll ever deploy in this
> tomcat instance, I have custom appenders that have static fields that are
> accessed from within the deployed webapp and through the log4j2 appender
> interface methods. Hence, log4j2 and the webapp need to use the same
> classloader (hierarchy), otherwise they'll be looking at teh same class
> loaded through different classloaders, thus different instances of the
> static field. I've got log4j2-web.jar and the jar containing my custom
> appenders both in the WEB-INF/lib folder of my webapp + a log4j2.properties
> in the WEB-INF folder, but then Log4J can't find the custom appenders. If I
> put the jar with the custom appenders on the classpath via Tomcat's
> setenv.sh, Log4J initializes properly, but the WebApp and Log4j seem to use
> 2 different classloaders, thus I run into the problem with multiple
> instances of the static field
> >>>
> >>> Is there any setup I can use that works in this scenario?
> >>>
> >>> Paul
> >>>
> >>> On 20/02/2019 12:26, Apache wrote:
> >>>> Ok. I will try it myself with both of those and let you know, but it
> might take a couple of days.
> >>>>
> >>>> Ralph
> >>>>
> >>>>> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
> >>>>>
> >>>>> With log4j-web on the classmate the INFO statements you mentioned
> >>>>> disappear, but the problem of internal tomcat logging via log4j isn't
> >>>>> solved.
> >>>>>
> >>>>> And I've went through but those links many times, tried everything I
> could
> >>>>> find there, but no avail
> >>>>>
> >>>>>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email]
> wrote:
> >>>>>>
> >>>>>> Hi Paul,
> >>>>>>
> >>>>>> Please try adding the log4j-web jar to the classpath:
> >>>>>>> INFO StatusLogger 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.
> >>>>>>
> >>>>>> Also, this user manual page may be useful:
> >>>>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe
> this
> >>>>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
> >>>>>>
> >>>>>> Remko.
> >>>>>>
> >>>>>> (Shameless plug) Every java main() method deserves
> http://picocli.info
> >>>>>>
> >>>>>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
> >>>>>>>
> >>>>>>> INFO StatusLogger 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.
> >>>>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: [hidden email]
> >>>> For additional commands, e-mail: [hidden email]
> >>>>
> >>> ---
> >>> This email has been checked for viruses by AVG.
> >>> https://www.avg.com
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden email]
> >>> For additional commands, e-mail: [hidden email]
> >>>
> >>>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> <mailto:[hidden email]>
> > For additional commands, e-mail: [hidden email]
> <mailto:[hidden email]>
>
Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Ralph Goers
If there the class exists in only one jar/directory then that class will only be loaded once by the class loader that manages the jar or directory. The only way you can have two instances of the class is if it is present in two different class loaders. In the case of Tomcat, that would mean it has to be present in both WEB-INF/lib or WEB-INF/classes and tomcat/lib.

I am still in the process of testing log4j-appserver with Tomcat 9. I will let you know what I find.

Ralph

> On Feb 22, 2019, at 12:30 PM, Paul <[hidden email]> wrote:
>
> The 'error' I get is that the static field on my custom appender class is
> null when accessed from my webapp, long after log4j is initialized, while
> the appender constructor that log4j called sets is value.
>
> And the access to that static field happens long after log4j is initialized.
>
> So my conclusion is that the appender class is loaded by multiple
> classloader
>
> Maybe it's using the java system classloader cause I'm using log4j-jul (as
> log4j-appserver doesn't work)?
>
> Paul
>
> On Fri, Feb 22, 2019, 7:27 PM Ralph Goers <[hidden email]>
> wrote:
>
>> Tomcat’s class loader will be a parent of the web app class loader. That
>> means the log4j-related classes placed in the tomcat class loader won’t be
>> able to access anything in your web-app class loader. But your application
>> should have no problem accessing them in tomcat’s class loader provided you
>> don’t also have them in your web-app.  That said, I haven’t looked at
>> Tomcat 9 yet. It is possible that they have an additional class loader that
>> is not in the parent hierarchy of the web-app class loader. If that is the
>> case your web app wouldn’t be able to access it. But then again, it
>> wouldn’t find Log4j either.
>>
>> What error do you get when you try to access the static fields?
>>
>> Ralph
>>
>>> On Feb 22, 2019, at 11:13 AM, Paul <[hidden email]> wrote:
>>>
>>> Hi Ralph,
>>>
>>> See in between the lines.
>>>
>>> Curious to hear what your take is on the classloader usage which is what
>> is causing my issues.
>>>
>>> Paul
>>>
>>> On 22/02/2019 18:43, Ralph Goers wrote:
>>>> I am not really clear on what you are trying to achieve so this answer
>> is making some guesses.
>>>>
>>>> A typical tomcat deployment will have a boot class loader, the tomcat
>> class loader and each web app will have its own class loader.  Tomcat’s
>> logging has to happen using Tomcat’s class loader while the web app uses a
>> combination of Tomcat’s and the Web Apps.
>>>>
>>>> It sounds like you want:
>>>> To use Log4j for tomcat logging.
>>>> To use Log4j for application logging.
>>>> To incorporate your own appenders for application logging.
>>> Correct
>>>>
>>>> What I am not clear about is if you have any custom stuff you want to
>> include for Tomcat logging. I am going to assume you don’t.
>>> Correct assumption, I don't need anything custom for Tomcat logging
>>>>
>>>> There are a couple of ways I would try to make this work. First, you
>> have to remember that in Tomcat the WebApp class loader is searched first
>> before delegating to the Tomcat class loader and that any classes in the
>> Tomcat class loader won’t be able to directly access classes in the Web App
>> class loader. If you place Log4j and your custom appenders in the tomcat
>> class loader and do not include them in your web app then everything should
>> work. However, if your custom appenders have dependencies on a bunch of
>> custom code this can get pretty ugly as they would need to be in tomcat/lib
>> as well.
>>>
>>> The custom appenders are standalone, they just have a public static
>> field that is accessed by code in my webapp.
>>>
>>> I tried doing as you described, but to no avail. It seems like the log4j
>> stuff isn't loaded using the bootstrap/system or common classloader, but
>> through the Java system classloader. What I don't understand is why the
>> log4j stuff seems loaded by the Java system classloader and not the Tomcat
>> classloaders... To my understanding: if any of the bootstrap/system or
>> common classloaders of Tomcat would be used, all would be good, as those
>> are all in the webapp classloader hierarchy, correct?
>>>
>>>>
>>>> Another way to deal with this would be to place the log4j jars in both
>> tomcat/lib and in the web application’s WEB-INF/lib. Tomcat will initialize
>> using the Log4j jars it finds in tomcat/lib. The web app should use the
>> log4j jars from WEB-INF lib. In that case you will essentially have two
>> separate log4j implementations, which is pretty much what you have to do to
>> accomplish what it sounds like you want.
>>> I haven't tried rolling two full log4j implementations, find that a bit
>> of waist of resources (@runtime, but also deployment-wise: we'll have many
>> containers running using this setup)
>>>>
>>>> Also, by default Log4j uses the ClassLoaderContextSelector. This
>> insures that there are two LoggerContexts - one for tomcat and one for your
>> web app. If you place everything in tomcat/lib you probably don’t want to
>> use that ContextSelector. You probably would want to use the
>> BasicContextSelector for that.
>>>>
>>>> Ralph
>>>>
>>>>> On Feb 22, 2019, at 9:27 AM, Paul <[hidden email]> wrote:
>>>>>
>>>>> Tnx
>>>>>
>>>>> I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16,
>> log4j2 2.11.2, Java 1.8.0_162) but the exact same problem.
>>>>>
>>>>> I've also looked at the docs on the Tomcat side: for Tomcat 9 the docs
>> on logging don't mention this mechanism to use log4j anymore. On the 8.0
>> documentation it is there, but talks about Log4j 1 and also details how you
>> need to replace the tomcat-juli(-adapters).jars, which I think is not
>> required anymore, see this case:
>> https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that case
>> seems to suggest that the way to replace tomcats internal logging is
>> through JUL....
>>>>>
>>>>> So, I gave JUL another shot:
>>>>>
>>>>> - with all the log4j-core/api/jul/ and a log4j2.properties on the
>> classpath set through  setenv.sh, I'm able to replace the internal logging
>> of Tomcat using Log4j2. So far so good.
>>>>>
>>>>> - For the logging from the single webaap/WAR I'll ever deploy in this
>> tomcat instance, I have custom appenders that have static fields that are
>> accessed from within the deployed webapp and through the log4j2 appender
>> interface methods. Hence, log4j2 and the webapp need to use the same
>> classloader (hierarchy), otherwise they'll be looking at teh same class
>> loaded through different classloaders, thus different instances of the
>> static field. I've got log4j2-web.jar and the jar containing my custom
>> appenders both in the WEB-INF/lib folder of my webapp + a log4j2.properties
>> in the WEB-INF folder, but then Log4J can't find the custom appenders. If I
>> put the jar with the custom appenders on the classpath via Tomcat's
>> setenv.sh, Log4J initializes properly, but the WebApp and Log4j seem to use
>> 2 different classloaders, thus I run into the problem with multiple
>> instances of the static field
>>>>>
>>>>> Is there any setup I can use that works in this scenario?
>>>>>
>>>>> Paul
>>>>>
>>>>> On 20/02/2019 12:26, Apache wrote:
>>>>>> Ok. I will try it myself with both of those and let you know, but it
>> might take a couple of days.
>>>>>>
>>>>>> Ralph
>>>>>>
>>>>>>> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
>>>>>>>
>>>>>>> With log4j-web on the classmate the INFO statements you mentioned
>>>>>>> disappear, but the problem of internal tomcat logging via log4j isn't
>>>>>>> solved.
>>>>>>>
>>>>>>> And I've went through but those links many times, tried everything I
>> could
>>>>>>> find there, but no avail
>>>>>>>
>>>>>>>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email]
>> wrote:
>>>>>>>>
>>>>>>>> Hi Paul,
>>>>>>>>
>>>>>>>> Please try adding the log4j-web jar to the classpath:
>>>>>>>>> INFO StatusLogger 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.
>>>>>>>>
>>>>>>>> Also, this user manual page may be useful:
>>>>>>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe
>> this
>>>>>>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>>>>>>>>
>>>>>>>> Remko.
>>>>>>>>
>>>>>>>> (Shameless plug) Every java main() method deserves
>> http://picocli.info
>>>>>>>>
>>>>>>>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
>>>>>>>>>
>>>>>>>>> INFO StatusLogger 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.
>>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>
>>>>> ---
>>>>> This email has been checked for viruses by AVG.
>>>>> https://www.avg.com
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>> <mailto:[hidden email]>
>>> For additional commands, e-mail: [hidden email]
>> <mailto:[hidden email]>
>>



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

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Paul
I'll double-check again, but I'm pretty confident the class is there only
once

On Fri, Feb 22, 2019, 9:33 PM Ralph Goers <[hidden email]>
wrote:

> If there the class exists in only one jar/directory then that class will
> only be loaded once by the class loader that manages the jar or directory.
> The only way you can have two instances of the class is if it is present in
> two different class loaders. In the case of Tomcat, that would mean it has
> to be present in both WEB-INF/lib or WEB-INF/classes and tomcat/lib.
>
> I am still in the process of testing log4j-appserver with Tomcat 9. I will
> let you know what I find.
>
> Ralph
>
> > On Feb 22, 2019, at 12:30 PM, Paul <[hidden email]> wrote:
> >
> > The 'error' I get is that the static field on my custom appender class is
> > null when accessed from my webapp, long after log4j is initialized, while
> > the appender constructor that log4j called sets is value.
> >
> > And the access to that static field happens long after log4j is
> initialized.
> >
> > So my conclusion is that the appender class is loaded by multiple
> > classloader
> >
> > Maybe it's using the java system classloader cause I'm using log4j-jul
> (as
> > log4j-appserver doesn't work)?
> >
> > Paul
> >
> > On Fri, Feb 22, 2019, 7:27 PM Ralph Goers <[hidden email]>
> > wrote:
> >
> >> Tomcat’s class loader will be a parent of the web app class loader. That
> >> means the log4j-related classes placed in the tomcat class loader won’t
> be
> >> able to access anything in your web-app class loader. But your
> application
> >> should have no problem accessing them in tomcat’s class loader provided
> you
> >> don’t also have them in your web-app.  That said, I haven’t looked at
> >> Tomcat 9 yet. It is possible that they have an additional class loader
> that
> >> is not in the parent hierarchy of the web-app class loader. If that is
> the
> >> case your web app wouldn’t be able to access it. But then again, it
> >> wouldn’t find Log4j either.
> >>
> >> What error do you get when you try to access the static fields?
> >>
> >> Ralph
> >>
> >>> On Feb 22, 2019, at 11:13 AM, Paul <[hidden email]> wrote:
> >>>
> >>> Hi Ralph,
> >>>
> >>> See in between the lines.
> >>>
> >>> Curious to hear what your take is on the classloader usage which is
> what
> >> is causing my issues.
> >>>
> >>> Paul
> >>>
> >>> On 22/02/2019 18:43, Ralph Goers wrote:
> >>>> I am not really clear on what you are trying to achieve so this answer
> >> is making some guesses.
> >>>>
> >>>> A typical tomcat deployment will have a boot class loader, the tomcat
> >> class loader and each web app will have its own class loader.  Tomcat’s
> >> logging has to happen using Tomcat’s class loader while the web app
> uses a
> >> combination of Tomcat’s and the Web Apps.
> >>>>
> >>>> It sounds like you want:
> >>>> To use Log4j for tomcat logging.
> >>>> To use Log4j for application logging.
> >>>> To incorporate your own appenders for application logging.
> >>> Correct
> >>>>
> >>>> What I am not clear about is if you have any custom stuff you want to
> >> include for Tomcat logging. I am going to assume you don’t.
> >>> Correct assumption, I don't need anything custom for Tomcat logging
> >>>>
> >>>> There are a couple of ways I would try to make this work. First, you
> >> have to remember that in Tomcat the WebApp class loader is searched
> first
> >> before delegating to the Tomcat class loader and that any classes in the
> >> Tomcat class loader won’t be able to directly access classes in the Web
> App
> >> class loader. If you place Log4j and your custom appenders in the tomcat
> >> class loader and do not include them in your web app then everything
> should
> >> work. However, if your custom appenders have dependencies on a bunch of
> >> custom code this can get pretty ugly as they would need to be in
> tomcat/lib
> >> as well.
> >>>
> >>> The custom appenders are standalone, they just have a public static
> >> field that is accessed by code in my webapp.
> >>>
> >>> I tried doing as you described, but to no avail. It seems like the
> log4j
> >> stuff isn't loaded using the bootstrap/system or common classloader, but
> >> through the Java system classloader. What I don't understand is why the
> >> log4j stuff seems loaded by the Java system classloader and not the
> Tomcat
> >> classloaders... To my understanding: if any of the bootstrap/system or
> >> common classloaders of Tomcat would be used, all would be good, as those
> >> are all in the webapp classloader hierarchy, correct?
> >>>
> >>>>
> >>>> Another way to deal with this would be to place the log4j jars in both
> >> tomcat/lib and in the web application’s WEB-INF/lib. Tomcat will
> initialize
> >> using the Log4j jars it finds in tomcat/lib. The web app should use the
> >> log4j jars from WEB-INF lib. In that case you will essentially have two
> >> separate log4j implementations, which is pretty much what you have to
> do to
> >> accomplish what it sounds like you want.
> >>> I haven't tried rolling two full log4j implementations, find that a bit
> >> of waist of resources (@runtime, but also deployment-wise: we'll have
> many
> >> containers running using this setup)
> >>>>
> >>>> Also, by default Log4j uses the ClassLoaderContextSelector. This
> >> insures that there are two LoggerContexts - one for tomcat and one for
> your
> >> web app. If you place everything in tomcat/lib you probably don’t want
> to
> >> use that ContextSelector. You probably would want to use the
> >> BasicContextSelector for that.
> >>>>
> >>>> Ralph
> >>>>
> >>>>> On Feb 22, 2019, at 9:27 AM, Paul <[hidden email]> wrote:
> >>>>>
> >>>>> Tnx
> >>>>>
> >>>>> I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16,
> >> log4j2 2.11.2, Java 1.8.0_162) but the exact same problem.
> >>>>>
> >>>>> I've also looked at the docs on the Tomcat side: for Tomcat 9 the
> docs
> >> on logging don't mention this mechanism to use log4j anymore. On the 8.0
> >> documentation it is there, but talks about Log4j 1 and also details how
> you
> >> need to replace the tomcat-juli(-adapters).jars, which I think is not
> >> required anymore, see this case:
> >> https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that
> case
> >> seems to suggest that the way to replace tomcats internal logging is
> >> through JUL....
> >>>>>
> >>>>> So, I gave JUL another shot:
> >>>>>
> >>>>> - with all the log4j-core/api/jul/ and a log4j2.properties on the
> >> classpath set through  setenv.sh, I'm able to replace the internal
> logging
> >> of Tomcat using Log4j2. So far so good.
> >>>>>
> >>>>> - For the logging from the single webaap/WAR I'll ever deploy in this
> >> tomcat instance, I have custom appenders that have static fields that
> are
> >> accessed from within the deployed webapp and through the log4j2 appender
> >> interface methods. Hence, log4j2 and the webapp need to use the same
> >> classloader (hierarchy), otherwise they'll be looking at teh same class
> >> loaded through different classloaders, thus different instances of the
> >> static field. I've got log4j2-web.jar and the jar containing my custom
> >> appenders both in the WEB-INF/lib folder of my webapp + a
> log4j2.properties
> >> in the WEB-INF folder, but then Log4J can't find the custom appenders.
> If I
> >> put the jar with the custom appenders on the classpath via Tomcat's
> >> setenv.sh, Log4J initializes properly, but the WebApp and Log4j seem to
> use
> >> 2 different classloaders, thus I run into the problem with multiple
> >> instances of the static field
> >>>>>
> >>>>> Is there any setup I can use that works in this scenario?
> >>>>>
> >>>>> Paul
> >>>>>
> >>>>> On 20/02/2019 12:26, Apache wrote:
> >>>>>> Ok. I will try it myself with both of those and let you know, but it
> >> might take a couple of days.
> >>>>>>
> >>>>>> Ralph
> >>>>>>
> >>>>>>> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
> >>>>>>>
> >>>>>>> With log4j-web on the classmate the INFO statements you mentioned
> >>>>>>> disappear, but the problem of internal tomcat logging via log4j
> isn't
> >>>>>>> solved.
> >>>>>>>
> >>>>>>> And I've went through but those links many times, tried everything
> I
> >> could
> >>>>>>> find there, but no avail
> >>>>>>>
> >>>>>>>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email]
> >> wrote:
> >>>>>>>>
> >>>>>>>> Hi Paul,
> >>>>>>>>
> >>>>>>>> Please try adding the log4j-web jar to the classpath:
> >>>>>>>>> INFO StatusLogger 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.
> >>>>>>>>
> >>>>>>>> Also, this user manual page may be useful:
> >>>>>>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and
> maybe
> >> this
> >>>>>>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
> >>>>>>>>
> >>>>>>>> Remko.
> >>>>>>>>
> >>>>>>>> (Shameless plug) Every java main() method deserves
> >> http://picocli.info
> >>>>>>>>
> >>>>>>>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
> >>>>>>>>>
> >>>>>>>>> INFO StatusLogger 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.
> >>>>>>>>
> >>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail: [hidden email]
> >>>>>> For additional commands, e-mail: [hidden email]
> >>>>>>
> >>>>> ---
> >>>>> This email has been checked for viruses by AVG.
> >>>>> https://www.avg.com
> >>>>>
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: [hidden email]
> >>>>> For additional commands, e-mail: [hidden email]
> >>>>>
> >>>>>
> >>>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden email]
> >> <mailto:[hidden email]>
> >>> For additional commands, e-mail: [hidden email]
> >> <mailto:[hidden email]>
> >>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Ralph Goers
I followed the instructions at http://logging.apache.org/log4j/2.x/log4j-appserver/index.html <http://logging.apache.org/log4j/2.x/log4j-appserver/index.html> with Tomcat 9 and I was able to have tomcat use Log4j for logging without any problems.  I will try adding a web app that uses Log4j 2 next.  Here is the output from startup.

NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
2019-02-22 16:14:42,708 main DEBUG Starting LoggerContext[name=Tomcat] from configuration at file:/opt/tomcat/apache-tomcat-9.0.16/log4j2/conf/log4j2-tomcat.xml
2019-02-22 16:14:42,711 main DEBUG Starting LoggerContext[name=Tomcat, org.apache.logging.log4j.core.LoggerContext@a1cdc6d] with configuration XmlConfiguration[location=/opt/tomcat/apache-tomcat-9.0.16/log4j2/conf/log4j2-tomcat.xml]...
2019-02-22 16:14:42,711 main DEBUG Shutdown hook enabled. Registering a new one.
2019-02-22 16:14:42,742 main DEBUG Apache Log4j Core 2.11.2 initializing configuration XmlConfiguration[location=/opt/tomcat/apache-tomcat-9.0.16/log4j2/conf/log4j2-tomcat.xml]
2019-02-22 16:14:42,747 main DEBUG Installed 1 script engine
Warning: Nashorn engine is planned to be removed from a future JDK release
2019-02-22 16:14:43,000 main DEBUG Oracle Nashorn version: 11, language: ECMAScript, threading: Not Thread Safe, compile: true, names: [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory
2019-02-22 16:14:43,000 main DEBUG PluginManager 'Core' found 117 plugins
2019-02-22 16:14:43,000 main DEBUG PluginManager 'Level' found 0 plugins
2019-02-22 16:14:43,004 main DEBUG Building Plugin[name=property, class=org.apache.logging.log4j.core.config.Property].
2019-02-22 16:14:43,012 main DEBUG PluginManager 'TypeConverter' found 26 plugins
2019-02-22 16:14:43,019 main DEBUG createProperty(name="logDir", value="/opt/tomcat/apache-tomcat-9.0.16/logs")
2019-02-22 16:14:43,020 main DEBUG Building Plugin[name=properties, class=org.apache.logging.log4j.core.config.PropertiesPlugin].
2019-02-22 16:14:43,023 main DEBUG configureSubstitutor(={logDir=/opt/tomcat/apache-tomcat-9.0.16/logs}, Configuration(tomcat))
2019-02-22 16:14:43,023 main DEBUG PluginManager 'Lookup' found 13 plugins
2019-02-22 16:14:43,024 main DEBUG Building Plugin[name=filter, class=org.apache.logging.log4j.core.filter.ThresholdFilter].
2019-02-22 16:14:43,025 main DEBUG createFilter(level="DEBUG", onMatch="null", onMismatch="null")
2019-02-22 16:14:43,025 main DEBUG Building Plugin[name=filters, class=org.apache.logging.log4j.core.filter.CompositeFilter].
2019-02-22 16:14:43,027 main DEBUG createFilters(={DEBUG})
2019-02-22 16:14:43,027 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2019-02-22 16:14:43,031 main DEBUG PatternLayout$Builder(pattern="%d %p %C{1.} [%t] %m%n", PatternSelector=null, Configuration(tomcat), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
2019-02-22 16:14:43,031 main DEBUG PluginManager 'Converter' found 44 plugins
2019-02-22 16:14:43,038 main DEBUG Building Plugin[name=TimeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy].
2019-02-22 16:14:43,041 main DEBUG TimeBasedTriggeringPolicy$Builder(interval="1", modulate="true", maxRandomDelay="null")
2019-02-22 16:14:43,042 main DEBUG Building Plugin[name=SizeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy].
2019-02-22 16:14:43,042 main DEBUG createPolicy(size="10MB")
2019-02-22 16:14:43,043 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.RollingFileAppender].
2019-02-22 16:14:43,048 main DEBUG RollingFileAppender$Builder(fileName="/opt/tomcat/apache-tomcat-9.0.16/logs/catalina.out", filePattern="/opt/tomcat/apache-tomcat-9.0.16/logs/catalina-%d{MM-dd-yy}.log.gz", append="null", locking="null", TimeBasedTriggeringPolicy(TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true)), Strategy=null, advertise="null", advertiseUri="null", createOnDemand="null", filePermissions="null", fileOwner="null", fileGroup="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%d %p %C{1.} [%t] %m%n), name="RollingFile", Configuration(tomcat), Filter=null, ={})
2019-02-22 16:14:43,048 main ERROR appender RollingFile has no parameter that matches element SizeBasedTriggeringPolicy
2019-02-22 16:14:43,054 main DEBUG Returning file creation time for /opt/tomcat/apache-tomcat-9.0.16/logs/catalina.out
2019-02-22 16:14:43,055 main DEBUG Starting RollingFileManager /opt/tomcat/apache-tomcat-9.0.16/logs/catalina.out
2019-02-22 16:14:43,057 main DEBUG PluginManager 'FileConverter' found 2 plugins
2019-02-22 16:14:43,058 main DEBUG Setting prev file time to 2019-02-22T16:14:42.000-0700
2019-02-22 16:14:43,059 main DEBUG Initializing triggering policy TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true)
2019-02-22 16:14:43,059 main DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
2019-02-22 16:14:43,060 main DEBUG createAppenders(={RollingFile})
2019-02-22 16:14:43,060 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2019-02-22 16:14:43,060 main DEBUG createAppenderRef(ref="RollingFile", level="null", Filter=null)
2019-02-22 16:14:43,061 main DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
2019-02-22 16:14:43,061 main DEBUG createLogger(additivity="null", level="INFO", includeLocation="null", ={RollingFile}, ={}, Configuration(tomcat), Filter=null)
2019-02-22 16:14:43,062 main DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
2019-02-22 16:14:43,063 main DEBUG createLoggers(={root})
2019-02-22 16:14:43,063 main DEBUG Configuration XmlConfiguration[location=/opt/tomcat/apache-tomcat-9.0.16/log4j2/conf/log4j2-tomcat.xml] initialized
2019-02-22 16:14:43,063 main DEBUG Starting configuration XmlConfiguration[location=/opt/tomcat/apache-tomcat-9.0.16/log4j2/conf/log4j2-tomcat.xml]
2019-02-22 16:14:43,064 main DEBUG Started configuration XmlConfiguration[location=/opt/tomcat/apache-tomcat-9.0.16/log4j2/conf/log4j2-tomcat.xml] OK.
2019-02-22 16:14:43,065 main DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false-1
2019-02-22 16:14:43,065 main DEBUG Shut down OutputStreamManager SYSTEM_OUT.false.false-1, all resources released: true
2019-02-22 16:14:43,065 main DEBUG Appender DefaultConsole-1 stopped with status true
2019-02-22 16:14:43,066 main DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration@704921a5 OK
2019-02-22 16:14:43,149 main DEBUG Registering MBean org.apache.logging.log4j2:type=Tomcat
2019-02-22 16:14:43,151 main DEBUG Registering MBean org.apache.logging.log4j2:type=Tomcat,component=StatusLogger
2019-02-22 16:14:43,152 main DEBUG Registering MBean org.apache.logging.log4j2:type=Tomcat,component=ContextSelector
2019-02-22 16:14:43,152 main DEBUG Registering MBean org.apache.logging.log4j2:type=Tomcat,component=Loggers,name=
2019-02-22 16:14:43,153 main DEBUG Registering MBean org.apache.logging.log4j2:type=Tomcat,component=Appenders,name=RollingFile
2019-02-22 16:14:43,156 main DEBUG org.apache.logging.log4j.core.util.SystemClock supports precise timestamps.
2019-02-22 16:14:43,156 main DEBUG LoggerContext[name=Tomcat, org.apache.logging.log4j.core.LoggerContext@a1cdc6d] started OK with configuration XmlConfiguration[location=/opt/tomcat/apache-tomcat-9.0.16/log4j2/conf/log4j2-tomcat.xml].
2019-02-22 16:14:43,369 INFO o.a.c.s.VersionLoggerListener [main] Server version name:   Apache Tomcat/9.0.16
2019-02-22 16:14:43,375 INFO o.a.c.s.VersionLoggerListener [main] Server built:          Feb 4 2019 16:30:29 UTC
2019-02-22 16:14:43,375 INFO o.a.c.s.VersionLoggerListener [main] Server version number: 9.0.16.0
2019-02-22 16:14:43,376 INFO o.a.c.s.VersionLoggerListener [main] OS Name:               Mac OS X
2019-02-22 16:14:43,376 INFO o.a.c.s.VersionLoggerListener [main] OS Version:            10.14.3
2019-02-22 16:14:43,376 INFO o.a.c.s.VersionLoggerListener [main] Architecture:          x86_64
2019-02-22 16:14:43,377 INFO o.a.c.s.VersionLoggerListener [main] Java Home:             /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
2019-02-22 16:14:43,377 INFO o.a.c.s.VersionLoggerListener [main] JVM Version:           11+28
2019-02-22 16:14:43,377 INFO o.a.c.s.VersionLoggerListener [main] JVM Vendor:            Oracle Corporation
2019-02-22 16:14:43,378 INFO o.a.c.s.VersionLoggerListener [main] CATALINA_BASE:         /opt/tomcat/apache-tomcat-9.0.16
2019-02-22 16:14:43,378 INFO o.a.c.s.VersionLoggerListener [main] CATALINA_HOME:         /opt/tomcat/apache-tomcat-9.0.16
2019-02-22 16:14:43,378 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
2019-02-22 16:14:43,378 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
2019-02-22 16:14:43,379 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
2019-02-22 16:14:43,379 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: -Djava.util.logging.config.file=/opt/tomcat/apache-tomcat-9.0.16/conf/logging.properties
2019-02-22 16:14:43,379 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
2019-02-22 16:14:43,379 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
2019-02-22 16:14:43,379 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
2019-02-22 16:14:43,380 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
2019-02-22 16:14:43,380 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: -Dignore.endorsed.dirs=
2019-02-22 16:14:43,380 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: -Dcatalina.base=/opt/tomcat/apache-tomcat-9.0.16
2019-02-22 16:14:43,380 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: -Dcatalina.home=/opt/tomcat/apache-tomcat-9.0.16
2019-02-22 16:14:43,380 INFO o.a.c.s.VersionLoggerListener [main] Command line argument: -Djava.io.tmpdir=/opt/tomcat/apache-tomcat-9.0.16/temp
2019-02-22 16:14:43,381 INFO o.a.c.c.AprLifecycleListener [main] The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/rgoers/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2019-02-22 16:14:43,411 INFO o.a.c.AbstractProtocol [main] Initializing ProtocolHandler ["http-nio-8080"]
2019-02-22 16:14:43,450 INFO o.a.c.AbstractProtocol [main] Initializing ProtocolHandler ["ajp-nio-8009"]
2019-02-22 16:14:43,452 INFO o.a.c.s.Catalina [main] Server initialization in [265] milliseconds
2019-02-22 16:14:43,495 INFO o.a.c.c.StandardService [main] Starting service [Catalina]
2019-02-22 16:14:43,495 INFO o.a.c.c.StandardEngine [main] Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-02-22 16:14:43,502 INFO o.a.c.s.HostConfig [main] Deploying web application directory [/opt/tomcat/apache-tomcat-9.0.16/webapps/docs]
2019-02-22 16:14:43,797 INFO o.a.c.s.HostConfig [main] Deployment of web application directory [/opt/tomcat/apache-tomcat-9.0.16/webapps/docs] has finished in [295] ms
2019-02-22 16:14:43,797 INFO o.a.c.s.HostConfig [main] Deploying web application directory [/opt/tomcat/apache-tomcat-9.0.16/webapps/manager]
2019-02-22 16:14:43,840 INFO o.a.c.s.HostConfig [main] Deployment of web application directory [/opt/tomcat/apache-tomcat-9.0.16/webapps/manager] has finished in [43] ms
2019-02-22 16:14:43,841 INFO o.a.c.s.HostConfig [main] Deploying web application directory [/opt/tomcat/apache-tomcat-9.0.16/webapps/examples]
2019-02-22 16:14:44,165 INFO o.a.c.c.ApplicationContext [main] ContextListener: contextInitialized()
2019-02-22 16:14:44,165 INFO o.a.c.c.ApplicationContext [main] SessionListener: contextInitialized()
2019-02-22 16:14:44,166 INFO o.a.c.c.ApplicationContext [main] ContextListener: attributeAdded('StockTicker', 'async.Stockticker@1976f537')
2019-02-22 16:14:44,170 INFO o.a.c.s.HostConfig [main] Deployment of web application directory [/opt/tomcat/apache-tomcat-9.0.16/webapps/examples] has finished in [329] ms
2019-02-22 16:14:44,170 INFO o.a.c.s.HostConfig [main] Deploying web application directory [/opt/tomcat/apache-tomcat-9.0.16/webapps/ROOT]
2019-02-22 16:14:44,186 INFO o.a.c.s.HostConfig [main] Deployment of web application directory [/opt/tomcat/apache-tomcat-9.0.16/webapps/ROOT] has finished in [16] ms
2019-02-22 16:14:44,186 INFO o.a.c.s.HostConfig [main] Deploying web application directory [/opt/tomcat/apache-tomcat-9.0.16/webapps/host-manager]
2019-02-22 16:14:44,202 INFO o.a.c.s.HostConfig [main] Deployment of web application directory [/opt/tomcat/apache-tomcat-9.0.16/webapps/host-manager] has finished in [16] ms
2019-02-22 16:14:44,207 INFO o.a.c.AbstractProtocol [main] Starting ProtocolHandler ["http-nio-8080"]
2019-02-22 16:14:44,217 INFO o.a.c.AbstractProtocol [main] Starting ProtocolHandler ["ajp-nio-8009"]
2019-02-22 16:14:44,220 INFO o.a.c.s.Catalina [main] Server startup in [767] milliseconds

Ralph

> On Feb 22, 2019, at 2:05 PM, Paul <[hidden email]> wrote:
>
> I'll double-check again, but I'm pretty confident the class is there only
> once
>
> On Fri, Feb 22, 2019, 9:33 PM Ralph Goers <[hidden email]>
> wrote:
>
>> If there the class exists in only one jar/directory then that class will
>> only be loaded once by the class loader that manages the jar or directory.
>> The only way you can have two instances of the class is if it is present in
>> two different class loaders. In the case of Tomcat, that would mean it has
>> to be present in both WEB-INF/lib or WEB-INF/classes and tomcat/lib.
>>
>> I am still in the process of testing log4j-appserver with Tomcat 9. I will
>> let you know what I find.
>>
>> Ralph
>>
>>> On Feb 22, 2019, at 12:30 PM, Paul <[hidden email]> wrote:
>>>
>>> The 'error' I get is that the static field on my custom appender class is
>>> null when accessed from my webapp, long after log4j is initialized, while
>>> the appender constructor that log4j called sets is value.
>>>
>>> And the access to that static field happens long after log4j is
>> initialized.
>>>
>>> So my conclusion is that the appender class is loaded by multiple
>>> classloader
>>>
>>> Maybe it's using the java system classloader cause I'm using log4j-jul
>> (as
>>> log4j-appserver doesn't work)?
>>>
>>> Paul
>>>
>>> On Fri, Feb 22, 2019, 7:27 PM Ralph Goers <[hidden email]>
>>> wrote:
>>>
>>>> Tomcat’s class loader will be a parent of the web app class loader. That
>>>> means the log4j-related classes placed in the tomcat class loader won’t
>> be
>>>> able to access anything in your web-app class loader. But your
>> application
>>>> should have no problem accessing them in tomcat’s class loader provided
>> you
>>>> don’t also have them in your web-app.  That said, I haven’t looked at
>>>> Tomcat 9 yet. It is possible that they have an additional class loader
>> that
>>>> is not in the parent hierarchy of the web-app class loader. If that is
>> the
>>>> case your web app wouldn’t be able to access it. But then again, it
>>>> wouldn’t find Log4j either.
>>>>
>>>> What error do you get when you try to access the static fields?
>>>>
>>>> Ralph
>>>>
>>>>> On Feb 22, 2019, at 11:13 AM, Paul <[hidden email]> wrote:
>>>>>
>>>>> Hi Ralph,
>>>>>
>>>>> See in between the lines.
>>>>>
>>>>> Curious to hear what your take is on the classloader usage which is
>> what
>>>> is causing my issues.
>>>>>
>>>>> Paul
>>>>>
>>>>> On 22/02/2019 18:43, Ralph Goers wrote:
>>>>>> I am not really clear on what you are trying to achieve so this answer
>>>> is making some guesses.
>>>>>>
>>>>>> A typical tomcat deployment will have a boot class loader, the tomcat
>>>> class loader and each web app will have its own class loader.  Tomcat’s
>>>> logging has to happen using Tomcat’s class loader while the web app
>> uses a
>>>> combination of Tomcat’s and the Web Apps.
>>>>>>
>>>>>> It sounds like you want:
>>>>>> To use Log4j for tomcat logging.
>>>>>> To use Log4j for application logging.
>>>>>> To incorporate your own appenders for application logging.
>>>>> Correct
>>>>>>
>>>>>> What I am not clear about is if you have any custom stuff you want to
>>>> include for Tomcat logging. I am going to assume you don’t.
>>>>> Correct assumption, I don't need anything custom for Tomcat logging
>>>>>>
>>>>>> There are a couple of ways I would try to make this work. First, you
>>>> have to remember that in Tomcat the WebApp class loader is searched
>> first
>>>> before delegating to the Tomcat class loader and that any classes in the
>>>> Tomcat class loader won’t be able to directly access classes in the Web
>> App
>>>> class loader. If you place Log4j and your custom appenders in the tomcat
>>>> class loader and do not include them in your web app then everything
>> should
>>>> work. However, if your custom appenders have dependencies on a bunch of
>>>> custom code this can get pretty ugly as they would need to be in
>> tomcat/lib
>>>> as well.
>>>>>
>>>>> The custom appenders are standalone, they just have a public static
>>>> field that is accessed by code in my webapp.
>>>>>
>>>>> I tried doing as you described, but to no avail. It seems like the
>> log4j
>>>> stuff isn't loaded using the bootstrap/system or common classloader, but
>>>> through the Java system classloader. What I don't understand is why the
>>>> log4j stuff seems loaded by the Java system classloader and not the
>> Tomcat
>>>> classloaders... To my understanding: if any of the bootstrap/system or
>>>> common classloaders of Tomcat would be used, all would be good, as those
>>>> are all in the webapp classloader hierarchy, correct?
>>>>>
>>>>>>
>>>>>> Another way to deal with this would be to place the log4j jars in both
>>>> tomcat/lib and in the web application’s WEB-INF/lib. Tomcat will
>> initialize
>>>> using the Log4j jars it finds in tomcat/lib. The web app should use the
>>>> log4j jars from WEB-INF lib. In that case you will essentially have two
>>>> separate log4j implementations, which is pretty much what you have to
>> do to
>>>> accomplish what it sounds like you want.
>>>>> I haven't tried rolling two full log4j implementations, find that a bit
>>>> of waist of resources (@runtime, but also deployment-wise: we'll have
>> many
>>>> containers running using this setup)
>>>>>>
>>>>>> Also, by default Log4j uses the ClassLoaderContextSelector. This
>>>> insures that there are two LoggerContexts - one for tomcat and one for
>> your
>>>> web app. If you place everything in tomcat/lib you probably don’t want
>> to
>>>> use that ContextSelector. You probably would want to use the
>>>> BasicContextSelector for that.
>>>>>>
>>>>>> Ralph
>>>>>>
>>>>>>> On Feb 22, 2019, at 9:27 AM, Paul <[hidden email]> wrote:
>>>>>>>
>>>>>>> Tnx
>>>>>>>
>>>>>>> I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16,
>>>> log4j2 2.11.2, Java 1.8.0_162) but the exact same problem.
>>>>>>>
>>>>>>> I've also looked at the docs on the Tomcat side: for Tomcat 9 the
>> docs
>>>> on logging don't mention this mechanism to use log4j anymore. On the 8.0
>>>> documentation it is there, but talks about Log4j 1 and also details how
>> you
>>>> need to replace the tomcat-juli(-adapters).jars, which I think is not
>>>> required anymore, see this case:
>>>> https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that
>> case
>>>> seems to suggest that the way to replace tomcats internal logging is
>>>> through JUL....
>>>>>>>
>>>>>>> So, I gave JUL another shot:
>>>>>>>
>>>>>>> - with all the log4j-core/api/jul/ and a log4j2.properties on the
>>>> classpath set through  setenv.sh, I'm able to replace the internal
>> logging
>>>> of Tomcat using Log4j2. So far so good.
>>>>>>>
>>>>>>> - For the logging from the single webaap/WAR I'll ever deploy in this
>>>> tomcat instance, I have custom appenders that have static fields that
>> are
>>>> accessed from within the deployed webapp and through the log4j2 appender
>>>> interface methods. Hence, log4j2 and the webapp need to use the same
>>>> classloader (hierarchy), otherwise they'll be looking at teh same class
>>>> loaded through different classloaders, thus different instances of the
>>>> static field. I've got log4j2-web.jar and the jar containing my custom
>>>> appenders both in the WEB-INF/lib folder of my webapp + a
>> log4j2.properties
>>>> in the WEB-INF folder, but then Log4J can't find the custom appenders.
>> If I
>>>> put the jar with the custom appenders on the classpath via Tomcat's
>>>> setenv.sh, Log4J initializes properly, but the WebApp and Log4j seem to
>> use
>>>> 2 different classloaders, thus I run into the problem with multiple
>>>> instances of the static field
>>>>>>>
>>>>>>> Is there any setup I can use that works in this scenario?
>>>>>>>
>>>>>>> Paul
>>>>>>>
>>>>>>> On 20/02/2019 12:26, Apache wrote:
>>>>>>>> Ok. I will try it myself with both of those and let you know, but it
>>>> might take a couple of days.
>>>>>>>>
>>>>>>>> Ralph
>>>>>>>>
>>>>>>>>> On Feb 19, 2019, at 11:58 PM, Paul <[hidden email]> wrote:
>>>>>>>>>
>>>>>>>>> With log4j-web on the classmate the INFO statements you mentioned
>>>>>>>>> disappear, but the problem of internal tomcat logging via log4j
>> isn't
>>>>>>>>> solved.
>>>>>>>>>
>>>>>>>>> And I've went through but those links many times, tried everything
>> I
>>>> could
>>>>>>>>> find there, but no avail
>>>>>>>>>
>>>>>>>>>> On Tue, Feb 19, 2019, 11:26 PM Remko Popma <[hidden email]
>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Hi Paul,
>>>>>>>>>>
>>>>>>>>>> Please try adding the log4j-web jar to the classpath:
>>>>>>>>>>> INFO StatusLogger 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.
>>>>>>>>>>
>>>>>>>>>> Also, this user manual page may be useful:
>>>>>>>>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and
>> maybe
>>>> this
>>>>>>>>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>>>>>>>>>>
>>>>>>>>>> Remko.
>>>>>>>>>>
>>>>>>>>>> (Shameless plug) Every java main() method deserves
>>>> http://picocli.info
>>>>>>>>>>
>>>>>>>>>>> On Feb 20, 2019, at 1:03, Paul <[hidden email]> wrote:
>>>>>>>>>>>
>>>>>>>>>>> INFO StatusLogger 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.
>>>>>>>>>>
>>>>>>>>
>>>>>>>>
>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>>>
>>>>>>> ---
>>>>>>> This email has been checked for viruses by AVG.
>>>>>>> https://www.avg.com
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>> <mailto:[hidden email]>
>>>>> For additional commands, e-mail: [hidden email]
>>>> <mailto:[hidden email]>
>>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Ralph Goers
In reply to this post by Paul
I just noticed that you said you have setenv.sh set to
CLASSPATH=“$CATALINA_HOME/lib/*”

That will find the jars but it won’t find your configuration file. You need to specify
CLASSPATH=“$CATALINA_HOME/lib/*:${CATALINA_HOME}/lib”

Note that lib is specified twice, once with “/*” after it and once with nothing.

Ralph

> On Feb 19, 2019, at 9:03 AM, Paul <[hidden email]> wrote:
>
> Hi,
>
> Am trying to get Tomcat to log internal stuff through Log4j2, but failing, no matter how I try.
>
> I've followed the instruction at https://logging.apache.org/log4j/2.x/log4j-appserver/index.html to no avail.
>
> I have a hard time understanding it, but maybe the problem is that the Log4j2 code is executed in a different classLoader than the tomcat code: I've enabled classloading debug output (-Xlog:class+load*=debug) and the status logger (-Dlog4j2.debug) and I see that all Tomcat code is executed by one classloader:
>
> loader: [loader data: 0x000055f64b4557e0 of 'bootstrap']
>
> whereas the Log4j2 code seems executed by a different classloader:
>
> loader: [loader data: 0x00005559e1327de0 for instance a 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x00000000e10c9c20}]
>
> I have this in setenv.sh and setenv.sh is working properly otherwise:
> CLASSPATH="$CATALINA_HOME/lib/*"
>
> The $CATALINA_HOME/lib/ contains my log4j2-tomcat.properties and the log4j-api and log4j-core jars (alongside slf4j-api.jar and log4j-slf4j-impl.jar).  (all version 2.11.x)
>
> I've also tried with the log4j-webon the classPath, didn't make a difference. Tried the -Dlog4j.ignoreTCL=true options, no luck.
>
> In the end, my main purpose it to log everything that happens in the JVM through log4j2 to the console. I've also tried with log4j-jul-2.11.1.jar, but couldn't get that going either: one of the challenges I have is that I have a custom appender plugin that needs to be loaded within the same classLoader hierarchy as where my (single) webapp is running. In the end, I'll be running only 1 webapp, deployed as a WAR in TOmcat and the whole thing is dockerized, so neither Tomcat or the WAR are ever restarted/redeployed: if something needs to change, we'll deploy a new container image
>
> The output to the console of Tomcat is this:
> Using CATALINA_BASE:   /usr/local/tomcat
> Using CATALINA_HOME:   /usr/local/tomcat
> Using CATALINA_TMPDIR: /usr/local/tomcat/temp
> Using JRE_HOME: /usr/lib/jvm/zulu11.2.3-jdk11.0.1-linux_musl_x64
> Using CLASSPATH: /usr/local/tomcat/lib/*:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
> NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
> NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
> DEBUG StatusLogger Using ShutdownCallbackRegistry class org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
> INFO StatusLogger 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.
> INFO StatusLogger 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.
> DEBUG StatusLogger Took 0.143572 seconds to load 208 plugins from jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
> DEBUG StatusLogger PluginManager 'Converter' found 44 plugins
> DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
> DEBUG StatusLogger Starting LoggerContext[name=799f7e29, org.apache.logging.log4j.core.LoggerContext@ae13544]...
> DEBUG StatusLogger Reconfiguration started for context[name=799f7e29] at URI null (org.apache.logging.log4j.core.LoggerContext@ae13544) with optional ClassLoader: null
> INFO StatusLogger 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.
> DEBUG StatusLogger PluginManager 'ConfigurationFactory' found 4 plugins
> INFO StatusLogger 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.
> INFO StatusLogger 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.
> DEBUG StatusLogger Missing dependencies for Yaml support, ConfigurationFactory org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory is inactive
> INFO StatusLogger 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.
> DEBUG StatusLogger Missing dependencies for Json support, ConfigurationFactory org.apache.logging.log4j.core.config.json.JsonConfigurationFactory is inactive
> INFO StatusLogger 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.
> DEBUG StatusLogger Using configurationFactory org.apache.logging.log4j.core.config.ConfigurationFactory$Factory@4e50c791
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.properties] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.yml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.yaml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.json] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.jsn] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2-test.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2-test.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2-test.xml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.properties] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.yml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.yaml] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.json] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.jsn] using ClassLoader.getSystemResource().
> TRACE StatusLogger Trying to find [log4j2.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
> TRACE StatusLogger Trying to find [log4j2.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
> TRACE StatusLogger Trying to find [log4j2.xml] using ClassLoader.getSystemResource().
> 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
> INFO StatusLogger 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.
>
>
> ---
> This email has been checked for viruses by AVG.
> https://www.avg.com
>
>
> ---------------------------------------------------------------------
> 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]

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Paul
Ghee, that was it, at least for getting the internal Tomcat logging to
go through Log4j.

It didn't solve my static field thing, but that one I also figured out.
Not 100% sure my reasoning is correct, but I think it's due to how
classloading works in Servlets and thus in Tomcat (by default): the
classloaders for webapps do NOT delegate classloading requests to the
parent classloader (by default), thus the same class can be loaded
multiple times: in my case by the bootstrap/system classloader and by
the webapp classloader. And I guess depending on how my webapp
application code tries to access the static field on the appender (don't
have insight to this code, it's a 3rd party framework), it doesn't find
the one where the appender constructor was called on, as my webapp code
gets the class loaded by the webapp classloader, whereas log4j seems to
load all plugins when log4j gets initialized the first time, which is
for Tomcat internal logging, which happens using the bootstrap/system
classloaders.

I tried adding the custom appenders to the WEB-INF/lib of my webapp
(while all other log4j jars live in the tomcat/lib), but this doesn't
work: the loading of log4j.properties in WEB-INF bombs out, because
log4j cannot find the custom appender.

Once I added <Loader delegate="true"/> to the Context, things started to
work. As I'm only deploying this one webapp, this works fine for me (or
so it seems).

If the above makes no sense or there are better ways to get things
going, I'd love to hear it

Tnx for the help so far!

Paul

On 23/02/2019 07:40, Ralph Goers wrote:

> I just noticed that you said you have setenv.sh set to
> CLASSPATH=“$CATALINA_HOME/lib/*”
>
> That will find the jars but it won’t find your configuration file. You need to specify
> CLASSPATH=“$CATALINA_HOME/lib/*:${CATALINA_HOME}/lib”
>
> Note that lib is specified twice, once with “/*” after it and once with nothing.
>
> Ralph
>
>> On Feb 19, 2019, at 9:03 AM, Paul <[hidden email]> wrote:
>>
>> Hi,
>>
>> Am trying to get Tomcat to log internal stuff through Log4j2, but failing, no matter how I try.
>>
>> I've followed the instruction at https://logging.apache.org/log4j/2.x/log4j-appserver/index.html to no avail.
>>
>> I have a hard time understanding it, but maybe the problem is that the Log4j2 code is executed in a different classLoader than the tomcat code: I've enabled classloading debug output (-Xlog:class+load*=debug) and the status logger (-Dlog4j2.debug) and I see that all Tomcat code is executed by one classloader:
>>
>> loader: [loader data: 0x000055f64b4557e0 of 'bootstrap']
>>
>> whereas the Log4j2 code seems executed by a different classloader:
>>
>> loader: [loader data: 0x00005559e1327de0 for instance a 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x00000000e10c9c20}]
>>
>> I have this in setenv.sh and setenv.sh is working properly otherwise:
>> CLASSPATH="$CATALINA_HOME/lib/*"
>>
>> The $CATALINA_HOME/lib/ contains my log4j2-tomcat.properties and the log4j-api and log4j-core jars (alongside slf4j-api.jar and log4j-slf4j-impl.jar).  (all version 2.11.x)
>>
>> I've also tried with the log4j-webon the classPath, didn't make a difference. Tried the -Dlog4j.ignoreTCL=true options, no luck.
>>
>> In the end, my main purpose it to log everything that happens in the JVM through log4j2 to the console. I've also tried with log4j-jul-2.11.1.jar, but couldn't get that going either: one of the challenges I have is that I have a custom appender plugin that needs to be loaded within the same classLoader hierarchy as where my (single) webapp is running. In the end, I'll be running only 1 webapp, deployed as a WAR in TOmcat and the whole thing is dockerized, so neither Tomcat or the WAR are ever restarted/redeployed: if something needs to change, we'll deploy a new container image
>>
>> The output to the console of Tomcat is this:
>> Using CATALINA_BASE:   /usr/local/tomcat
>> Using CATALINA_HOME:   /usr/local/tomcat
>> Using CATALINA_TMPDIR: /usr/local/tomcat/temp
>> Using JRE_HOME: /usr/lib/jvm/zulu11.2.3-jdk11.0.1-linux_musl_x64
>> Using CLASSPATH: /usr/local/tomcat/lib/*:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
>> NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
>> NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
>> DEBUG StatusLogger Using ShutdownCallbackRegistry class org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
>> INFO StatusLogger 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.
>> INFO StatusLogger 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.
>> DEBUG StatusLogger Took 0.143572 seconds to load 208 plugins from jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>> DEBUG StatusLogger PluginManager 'Converter' found 44 plugins
>> DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
>> DEBUG StatusLogger Starting LoggerContext[name=799f7e29, org.apache.logging.log4j.core.LoggerContext@ae13544]...
>> DEBUG StatusLogger Reconfiguration started for context[name=799f7e29] at URI null (org.apache.logging.log4j.core.LoggerContext@ae13544) with optional ClassLoader: null
>> INFO StatusLogger 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.
>> DEBUG StatusLogger PluginManager 'ConfigurationFactory' found 4 plugins
>> INFO StatusLogger 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.
>> INFO StatusLogger 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.
>> DEBUG StatusLogger Missing dependencies for Yaml support, ConfigurationFactory org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory is inactive
>> INFO StatusLogger 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.
>> DEBUG StatusLogger Missing dependencies for Json support, ConfigurationFactory org.apache.logging.log4j.core.config.json.JsonConfigurationFactory is inactive
>> INFO StatusLogger 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.
>> DEBUG StatusLogger Using configurationFactory org.apache.logging.log4j.core.config.ConfigurationFactory$Factory@4e50c791
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.properties] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.yml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.yaml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.json] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.jsn] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2-test.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2-test.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2-test.xml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.properties] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.yml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.yaml] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.json] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.jsn] using ClassLoader.getSystemResource().
>> TRACE StatusLogger Trying to find [log4j2.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>> TRACE StatusLogger Trying to find [log4j2.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>> TRACE StatusLogger Trying to find [log4j2.xml] using ClassLoader.getSystemResource().
>> 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
>> INFO StatusLogger 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.
>>
>>
>> ---
>> This email has been checked for viruses by AVG.
>> https://www.avg.com
>>
>>
>> ---------------------------------------------------------------------
>> 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]
>

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

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Ralph Goers
I have been able to get this working but I have not yet added a Plugin to validate the last part. I placed the log4j-api, log4j-core, and log4j-appserver jars in the directory picked up by the bootstrap class loader along with the log4j2-tomcat.xml. That successfully used log4j for logging. I then created a web app that included the log4j-api, log4j-core, log4j-web and log4j-jcl jars are dependencies. The log4j2.xml was placed into WEB-INF/classes. That was able to configure properly. I could tell it was using the version of log4j in the web app because LogManager initialized twice, once for tomcat and once for the web app. It would have only initialized once if the same LogManager was used.

While debugging I found that the web app did not work without log4j-web. This seemed to be because log4j-web uses the Configurator class which specifically calls ConfigurationFactory.getConfiguration to search for a configuration if one is not provided. Without it that search was not happening. There may be other ways to get that to work but I didn’t investigate that.

Ralph

> On Feb 24, 2019, at 2:46 AM, Paul <[hidden email]> wrote:
>
> Ghee, that was it, at least for getting the internal Tomcat logging to go through Log4j.
>
> It didn't solve my static field thing, but that one I also figured out. Not 100% sure my reasoning is correct, but I think it's due to how classloading works in Servlets and thus in Tomcat (by default): the classloaders for webapps do NOT delegate classloading requests to the parent classloader (by default), thus the same class can be loaded multiple times: in my case by the bootstrap/system classloader and by the webapp classloader. And I guess depending on how my webapp application code tries to access the static field on the appender (don't have insight to this code, it's a 3rd party framework), it doesn't find the one where the appender constructor was called on, as my webapp code gets the class loaded by the webapp classloader, whereas log4j seems to load all plugins when log4j gets initialized the first time, which is for Tomcat internal logging, which happens using the bootstrap/system classloaders.
>
> I tried adding the custom appenders to the WEB-INF/lib of my webapp (while all other log4j jars live in the tomcat/lib), but this doesn't work: the loading of log4j.properties in WEB-INF bombs out, because log4j cannot find the custom appender.
>
> Once I added <Loader delegate="true"/> to the Context, things started to work. As I'm only deploying this one webapp, this works fine for me (or so it seems).
>
> If the above makes no sense or there are better ways to get things going, I'd love to hear it
>
> Tnx for the help so far!
>
> Paul
>
> On 23/02/2019 07:40, Ralph Goers wrote:
>> I just noticed that you said you have setenv.sh set to
>> CLASSPATH=“$CATALINA_HOME/lib/*”
>>
>> That will find the jars but it won’t find your configuration file. You need to specify
>> CLASSPATH=“$CATALINA_HOME/lib/*:${CATALINA_HOME}/lib”
>>
>> Note that lib is specified twice, once with “/*” after it and once with nothing.
>>
>> Ralph
>>
>>> On Feb 19, 2019, at 9:03 AM, Paul <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> Am trying to get Tomcat to log internal stuff through Log4j2, but failing, no matter how I try.
>>>
>>> I've followed the instruction at https://logging.apache.org/log4j/2.x/log4j-appserver/index.html to no avail.
>>>
>>> I have a hard time understanding it, but maybe the problem is that the Log4j2 code is executed in a different classLoader than the tomcat code: I've enabled classloading debug output (-Xlog:class+load*=debug) and the status logger (-Dlog4j2.debug) and I see that all Tomcat code is executed by one classloader:
>>>
>>> loader: [loader data: 0x000055f64b4557e0 of 'bootstrap']
>>>
>>> whereas the Log4j2 code seems executed by a different classloader:
>>>
>>> loader: [loader data: 0x00005559e1327de0 for instance a 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x00000000e10c9c20}]
>>>
>>> I have this in setenv.sh and setenv.sh is working properly otherwise:
>>> CLASSPATH="$CATALINA_HOME/lib/*"
>>>
>>> The $CATALINA_HOME/lib/ contains my log4j2-tomcat.properties and the log4j-api and log4j-core jars (alongside slf4j-api.jar and log4j-slf4j-impl.jar).  (all version 2.11.x)
>>>
>>> I've also tried with the log4j-webon the classPath, didn't make a difference. Tried the -Dlog4j.ignoreTCL=true options, no luck.
>>>
>>> In the end, my main purpose it to log everything that happens in the JVM through log4j2 to the console. I've also tried with log4j-jul-2.11.1.jar, but couldn't get that going either: one of the challenges I have is that I have a custom appender plugin that needs to be loaded within the same classLoader hierarchy as where my (single) webapp is running. In the end, I'll be running only 1 webapp, deployed as a WAR in TOmcat and the whole thing is dockerized, so neither Tomcat or the WAR are ever restarted/redeployed: if something needs to change, we'll deploy a new container image
>>>
>>> The output to the console of Tomcat is this:
>>> Using CATALINA_BASE:   /usr/local/tomcat
>>> Using CATALINA_HOME:   /usr/local/tomcat
>>> Using CATALINA_TMPDIR: /usr/local/tomcat/temp
>>> Using JRE_HOME: /usr/lib/jvm/zulu11.2.3-jdk11.0.1-linux_musl_x64
>>> Using CLASSPATH: /usr/local/tomcat/lib/*:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
>>> NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
>>> NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
>>> DEBUG StatusLogger Using ShutdownCallbackRegistry class org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
>>> INFO StatusLogger 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.
>>> INFO StatusLogger 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.
>>> DEBUG StatusLogger Took 0.143572 seconds to load 208 plugins from jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> DEBUG StatusLogger PluginManager 'Converter' found 44 plugins
>>> DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
>>> DEBUG StatusLogger Starting LoggerContext[name=799f7e29, org.apache.logging.log4j.core.LoggerContext@ae13544]...
>>> DEBUG StatusLogger Reconfiguration started for context[name=799f7e29] at URI null (org.apache.logging.log4j.core.LoggerContext@ae13544) with optional ClassLoader: null
>>> INFO StatusLogger 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.
>>> DEBUG StatusLogger PluginManager 'ConfigurationFactory' found 4 plugins
>>> INFO StatusLogger 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.
>>> INFO StatusLogger 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.
>>> DEBUG StatusLogger Missing dependencies for Yaml support, ConfigurationFactory org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory is inactive
>>> INFO StatusLogger 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.
>>> DEBUG StatusLogger Missing dependencies for Json support, ConfigurationFactory org.apache.logging.log4j.core.config.json.JsonConfigurationFactory is inactive
>>> INFO StatusLogger 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.
>>> DEBUG StatusLogger Using configurationFactory org.apache.logging.log4j.core.config.ConfigurationFactory$Factory@4e50c791
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.yaml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.json] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.jsn] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test799f7e29.xml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.properties] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.yml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.yaml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.json] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.jsn] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2-test.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2-test.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2-test.xml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.properties] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.yml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.properties] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.properties] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2.yml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.yml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.yml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2.yaml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.yaml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.yaml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2.json] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.json] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.json] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2.jsn] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.jsn] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.jsn] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2.xml] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29.
>>> TRACE StatusLogger Trying to find [log4j2.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.xml] using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class loader.
>>> TRACE StatusLogger Trying to find [log4j2.xml] using ClassLoader.getSystemResource().
>>> 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
>>> INFO StatusLogger 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.
>>>
>>>
>>> ---
>>> This email has been checked for viruses by AVG.
>>> https://www.avg.com
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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]
>>
>
> ---------------------------------------------------------------------
> 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]

Reply | Threaded
Open this post in threaded view
|

Re: Application Server integration in Tomcat

Christopher Schultz-2
In reply to this post by Paul
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Paul,

On 2/24/19 04:46, Paul wrote:

> Ghee, that was it, at least for getting the internal Tomcat logging
> to go through Log4j.
>
> It didn't solve my static field thing, but that one I also figured
> out. Not 100% sure my reasoning is correct, but I think it's due to
> how classloading works in Servlets and thus in Tomcat (by default):
> the classloaders for webapps do NOT delegate classloading requests
> to the parent classloader (by default), thus the same class can be
> loaded multiple times: in my case by the bootstrap/system
> classloader and by the webapp classloader. And I guess depending on
> how my webapp application code tries to access the static field on
> the appender (don't have insight to this code, it's a 3rd party
> framework), it doesn't find the one where the appender constructor
> was called on, as my webapp code gets the class loaded by the
> webapp classloader, whereas log4j seems to load all plugins when
> log4j gets initialized the first time, which is for Tomcat internal
> logging, which happens using the bootstrap/system classloaders.
>
> I tried adding the custom appenders to the WEB-INF/lib of my
> webapp (while all other log4j jars live in the tomcat/lib), but
> this doesn't work: the loading of log4j.properties in WEB-INF bombs
> out, because log4j cannot find the custom appender.
>
> Once I added <Loader delegate="true"/> to the Context, things
> started to work. As I'm only deploying this one webapp, this works
> fine for me (or so it seems).
>
> If the above makes no sense or there are better ways to get things
> going, I'd love to hear it

So you want Tomcat's internal logging to go through log4j with a
configuration file in CATALINA_HOME/lib/log4j.xml and then you also
want your individual applications to use log4j with their own
WEB-INF/classes/log4j.xml and both Tomcat and applications need a
custom appender?

No problem.

Just put all of [ log4j JAR file, your custom appender JAR, log4j.xml]
into CATALINA_HOME/lib *and also* into WEB-INF/lib/*.jar,
WEB-INF/classes/log4j.xml and you should be good to go.

Dumb question: why bother using log4j for Tomcat server-level logging?
If you want to dump to the console, just configure Tomcat to dump to
the console and forget all this additional work.

- -chris

> On 23/02/2019 07:40, Ralph Goers wrote:
>> I just noticed that you said you have setenv.sh set to
>> CLASSPATH=“$CATALINA_HOME/lib/*”
>>
>> That will find the jars but it won’t find your configuration
>> file. You need to specify
>> CLASSPATH=“$CATALINA_HOME/lib/*:${CATALINA_HOME}/lib”
>>
>> Note that lib is specified twice, once with “/*” after it and
>> once with nothing.
>>
>> Ralph
>>
>>> On Feb 19, 2019, at 9:03 AM, Paul <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> Am trying to get Tomcat to log internal stuff through Log4j2,
>>> but failing, no matter how I try.
>>>
>>> I've followed the instruction at
>>> https://logging.apache.org/log4j/2.x/log4j-appserver/index.html
>>> to no avail.
>>>
>>> I have a hard time understanding it, but maybe the problem is
>>> that the Log4j2 code is executed in a different classLoader
>>> than the tomcat code: I've enabled classloading debug output
>>> (-Xlog:class+load*=debug) and the status logger
>>> (-Dlog4j2.debug) and I see that all Tomcat code is executed by
>>> one classloader:
>>>
>>> loader: [loader data: 0x000055f64b4557e0 of 'bootstrap']
>>>
>>> whereas the Log4j2 code seems executed by a different
>>> classloader:
>>>
>>> loader: [loader data: 0x00005559e1327de0 for instance a
>>> 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x00000000e10c9c20
}]
>>>
>>>
>>>
I have this in setenv.sh and setenv.sh is working properly otherwise:

>>> CLASSPATH="$CATALINA_HOME/lib/*"
>>>
>>> The $CATALINA_HOME/lib/ contains my log4j2-tomcat.properties
>>> and the log4j-api and log4j-core jars (alongside slf4j-api.jar
>>> and log4j-slf4j-impl.jar).  (all version 2.11.x)
>>>
>>> I've also tried with the log4j-webon the classPath, didn't make
>>> a difference. Tried the -Dlog4j.ignoreTCL=true options, no
>>> luck.
>>>
>>> In the end, my main purpose it to log everything that happens
>>> in the JVM through log4j2 to the console. I've also tried with
>>> log4j-jul-2.11.1.jar, but couldn't get that going either: one
>>> of the challenges I have is that I have a custom appender
>>> plugin that needs to be loaded within the same classLoader
>>> hierarchy as where my (single) webapp is running. In the end,
>>> I'll be running only 1 webapp, deployed as a WAR in TOmcat and
>>> the whole thing is dockerized, so neither Tomcat or the WAR are
>>> ever restarted/redeployed: if something needs to change, we'll
>>> deploy a new container image
>>>
>>> The output to the console of Tomcat is this: Using
>>> CATALINA_BASE:   /usr/local/tomcat Using CATALINA_HOME:
>>> /usr/local/tomcat Using CATALINA_TMPDIR:
>>> /usr/local/tomcat/temp Using JRE_HOME:
>>> /usr/lib/jvm/zulu11.2.3-jdk11.0.1-linux_musl_x64 Using
>>> CLASSPATH:
>>> /usr/local/tomcat/lib/*:/usr/local/tomcat/bin/bootstrap.jar:/usr/loc
al/tomcat/bin/tomcat-juli.jar
>>>
>>>
>>>
NOTE: Picked up JDK_JAVA_OPTIONS:

>>> --add-opens=java.base/java.lang=ALL-UNNAMED
>>> --add-opens=java.base/java.io=ALL-UNNAMED
>>> --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED NOTE: Picked
>>> up JDK_JAVA_OPTIONS:
>>> --add-opens=java.base/java.lang=ALL-UNNAMED
>>> --add-opens=java.base/java.io=ALL-UNNAMED
>>> --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED DEBUG
>>> StatusLogger Using ShutdownCallbackRegistry class
>>> org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
>>>
>>>
INFO StatusLogger 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. INFO StatusLogger
>>> 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. DEBUG StatusLogger Took
>>> 0.143572 seconds to load 208 plugins from
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 DEBUG
>>> StatusLogger PluginManager 'Converter' found 44 plugins DEBUG
>>> StatusLogger Starting OutputStreamManager
>>> SYSTEM_OUT.false.false-1 DEBUG StatusLogger Starting
>>> LoggerContext[name=799f7e29,
>>> org.apache.logging.log4j.core.LoggerContext@ae13544]... DEBUG
>>> StatusLogger Reconfiguration started for
>>> context[name=799f7e29] at URI null
>>> (org.apache.logging.log4j.core.LoggerContext@ae13544) with
>>> optional ClassLoader: null INFO StatusLogger 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. DEBUG StatusLogger PluginManager
>>> 'ConfigurationFactory' found 4 plugins INFO StatusLogger 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. INFO StatusLogger 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. DEBUG StatusLogger Missing dependencies for Yaml
>>> support, ConfigurationFactory
>>> org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory
>>> is inactive INFO StatusLogger 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.
>>> DEBUG StatusLogger Missing dependencies for Json support,
>>> ConfigurationFactory
>>> org.apache.logging.log4j.core.config.json.JsonConfigurationFactory
>>> is inactive INFO StatusLogger 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.
>>> DEBUG StatusLogger Using configurationFactory
>>> org.apache.logging.log4j.core.config.ConfigurationFactory$Factory@4e
50c791
>>>
>>>
>>>
TRACE StatusLogger Trying to find [log4j2-test799f7e29.properties]

>>> using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test799f7e29.properties]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.properties] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.properties] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2-test799f7e29.yml] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test799f7e29.yml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.yml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.yml] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2-test799f7e29.yaml] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test799f7e29.yaml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.yaml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.yaml] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2-test799f7e29.json] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test799f7e29.json] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.json] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.json] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2-test799f7e29.jsn] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test799f7e29.jsn] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.jsn] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.jsn] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2-test799f7e29.xml] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test799f7e29.xml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.xml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test799f7e29.xml] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2-test.properties] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test.properties] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test.properties] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2-test.properties] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2-test.yml] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test.yml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2-test.yml]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2-test.yml] using ClassLoader.getSystemResource(). TRACE
>>> StatusLogger Trying to find [log4j2-test.yaml] using context
>>> class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test.yaml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2-test.yaml]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2-test.yaml] using ClassLoader.getSystemResource(). TRACE
>>> StatusLogger Trying to find [log4j2-test.json] using context
>>> class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test.json] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2-test.json]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2-test.json] using ClassLoader.getSystemResource(). TRACE
>>> StatusLogger Trying to find [log4j2-test.jsn] using context
>>> class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test.jsn] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2-test.jsn]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2-test.jsn] using ClassLoader.getSystemResource(). TRACE
>>> StatusLogger Trying to find [log4j2-test.xml] using context
>>> class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2-test.xml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2-test.xml]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2-test.xml] using ClassLoader.getSystemResource(). TRACE
>>> StatusLogger Trying to find [log4j2799f7e29.properties] using
>>> context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2799f7e29.properties] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2799f7e29.properties] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find
>>> [log4j2799f7e29.properties] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2799f7e29.yml] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2799f7e29.yml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2799f7e29.yml]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2799f7e29.yml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.yaml] using
>>> context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2799f7e29.yaml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2799f7e29.yaml]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2799f7e29.yaml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.json] using
>>> context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2799f7e29.json] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2799f7e29.json]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2799f7e29.json] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.jsn] using
>>> context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2799f7e29.jsn] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2799f7e29.jsn]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2799f7e29.jsn] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2799f7e29.xml] using
>>> context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2799f7e29.xml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2799f7e29.xml]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2799f7e29.xml] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2.properties] using
>>> context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2.properties] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.properties]
>>> using jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29
>>> class loader. TRACE StatusLogger Trying to find
>>> [log4j2.properties] using ClassLoader.getSystemResource().
>>> TRACE StatusLogger Trying to find [log4j2.yml] using context
>>> class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2.yml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.yml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.yml] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2.yaml] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2.yaml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.yaml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.yaml] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2.json] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2.json] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.json] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.json] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2.jsn] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2.jsn] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.jsn] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.jsn] using
>>> ClassLoader.getSystemResource(). TRACE StatusLogger Trying to
>>> find [log4j2.xml] using context class loader
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29. TRACE
>>> StatusLogger Trying to find [log4j2.xml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.xml] using
>>> jdk.internal.loader.ClassLoaders$AppClassLoader@799f7e29 class
>>> loader. TRACE StatusLogger Trying to find [log4j2.xml] using
>>> ClassLoader.getSystemResource(). 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 INFO StatusLogger
>>> 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.
>>>
>>>
>>> --- This email has been checked for viruses by AVG.
>>> https://www.avg.com
>>>
>>>
>>> --------------------------------------------------------------------
- -
>>>
>>>
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]
>>
>
> ---------------------------------------------------------------------
>
>
To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail:
> [hidden email]
>
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxz9KYACgkQHPApP6U8
pFjAaBAAgapoJB+Apsm7yp1Z64zfVTNsAySwnrktWtFiAOoZi0UFCKiNkgQBFaLQ
VmqtjTcBysQIHdMLzFbKL+2eGzmeJq36UI4H73oXe+mm1jMjBWaT+FVo3SjjudYb
bOs4UP8KbxIZ0Ku2KA84Tg6KCjossK5CFdzRlybJURUaazdXdQHcP7ZN6Dm+aQiX
ST2j3a0txSrPD/x2G72bnKBpD+J9weqteUGNA/UCKC5k1oGSjNRFj5f4BBL/fW2+
obyA/WGCFpPJx02lfSyRodsJPojAjAeGTK65Ba9cU2X2GLUf/pOMSJVqzi8IPcau
5YXD6Nn/saVsMFkO9Fh3ecjc5+gswHGN3zodlEoHKYKmd8LRy2LKkSqj6Icd0++L
BVN+qxucu9cb1Ykzk0tSUrMnQrJ82BggheaOd6jzc319Y14E/VUVw80P0cgEFppk
7Fs/K5JB+B8WuhRp8BK2o57frfHbUKq8vQaxghIMkCYge6KAV0wZ824neitAW/4Q
CYjgtgBxhEazLNIkqKinQOaaf7l0FPH3qWCeaTH9GLipJKT793eJqtmf9VgbUkfH
58pa62cIFfAR95kCHBSLS2QXdZw1p/nr1257dls/su4aPT8zIlVe9MFmi3StH164
ItEMqa/iaNxR8IxOQOc61f3k8xMBrGV28WDjz4HVwCjSNxMd1ic=
=jIfR
-----END PGP SIGNATURE-----

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

12