logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Kellerman <david_keller...@nls.com>
Subject Converting log4j.properties file for Tomcat to work with Log4j2
Date Sat, 03 Jan 2015 19:08:32 GMT
(I originally posted a version of this question to stackoverflow, where it was suggested 
I might find more knowledgeable help on an apache mailing list.)

I'm trying to configure Tomcat 8 (Apache Tomcat/8.0.14 (Debian)) to use Log4j 2.1 
for logging.

I've found this reference for Logging in Tomcat using Log4j (not Log4j 2): 
http://tomcat.apache.org/tomcat-8.0-doc/logging.html#Using_Log4j. It provides a 
sample log4j.properties file that configures Log4j to match Tomcat's internal logging. 
Most of this looks pretty straightforward to convert for Log4j2, but the section at the 
end that maps loggers to appenders has me stumped:

    # Configure which loggers log to which appenders
    log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost] = INFO, LOCALHOST
    log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager]
=\
      INFO, MANAGER
    log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager]
=\
      INFO, HOST-MANAGER

Has anyone converted this configuration to work with Log4j2? I've been working 
from the Log4j2 configuration documentation and have read through the Log4j2 
Architecture page, but I haven't found much material (examples, in particular) on 
how to do this sort of container mapping in Log4j2.

I suppose I could do a separate configuration for each container, but I'd prefer to 
keep it in one place, as in the sample Log4j configuration.

Thanks!


Mime
View raw message