logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Log4J2 and Tomcat: multiple external config files
Date Thu, 10 Jan 2013 17:27:06 GMT
LOG4J2-18 and LOG4J2-42 have been sitting for quite some time waiting for someone like yourself
to come along and help come up with good approaches.

I think most of the tools are there but I'm not sure what the best way(s) is/are to finish
it off.

First, hopefully you are aware that the default ContextSelector is the ClassLoaderContextSelector.
If you place your Log4j 2 jars in the tomcat class loader then Tomcat's logging will use the
Logging Context associated with Tomcat's class loader. That would need to use log4j2.xml or
the system property - unless something can be added to Tomcat startup that causes it to use
a different configuration file via the Configurator.  All the web applications will have their
own logging contexts that is associated with their class loader. If you use the Log4jContextListener
in the web project and can configure each web apps web.xml then you can cause each web app
to have their own configuration or you can set them to all use the same one.  I suppose we
could also modify the context listener to look for a system property to automatically cause
all the web apps to share a configuration.

With the BasicContextSelector everything uses a single LoggerContext so that probably isn't
what you want.

With the JNDIContextSelector each web app does a JNDI lookup to locate its LoggerContext.
Again, you would need to configure each web app with the location of the configuration file.

I'm open to suggestions on how to better handle this.

Ralph 


On Jan 10, 2013, at 8:56 AM, Scott Severtson wrote:

> All,
> 
> We'd like to replace Tomcat's built-in logging with Log4J2, and are able to do so based
on Tomcat's docs for using Log4J 1.x, and deploying the log4j-1.2-api-2.0-beta4.jar shim.
> 
> However, we're running into an issue with external configuration...
> 
> Our webapps are always deployed with external logging configuration files. Historically,
we've used -Dlog4j.configuration=/path/to/log4j.properties (now -Dlog4j.configurationFile=/path/to/log4j2.xml)
to point the app to the correct file.
> 
> Unfortunately, if we pass the app-specific config file to the Tomcat JVM, the Tomcat-level
Log4J2 instance *also* tries to that config file.
> 
> Is there a reasonable way to support externalized configuration files both for the Tomcat-level
Log4J2 instance, *and* app-specific external configuration files as well?
> 
> Many thanks,
> --Scott
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message