Skip to content

Instantly share code, notes, and snippets.

@collinpeters
Created May 31, 2012 20:05
Show Gist options
  • Save collinpeters/2845875 to your computer and use it in GitHub Desktop.
Save collinpeters/2845875 to your computer and use it in GitHub Desktop.
log4j.properties to replace Tomcat internal logging, using RollingFileAppender
log4j.rootLogger=INFO, CATALINA
# Define all the appenders
log4j.appender.CATALINA=org.apache.log4j.RollingFileAppender
log4j.appender.CATALINA.File=${catalina.home}/logs/catalina.out
log4j.appender.CATALINA.MaxFileSize=100MB
log4j.appender.CATALINA.MaxBackupIndex=5
log4j.appender.CATALINA.layout=org.apache.log4j.PatternLayout
log4j.appender.CATALINA.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} %p-%c{1}: [%m]%n
log4j.appender.CATALINA.Append=true
log4j.appender.CATALINA.Encoding=UTF-8
log4j.appender.LOCALHOST=org.apache.log4j.RollingFileAppender
# Also log LOCALHOST to catalina.out
log4j.appender.LOCALHOST.File=${catalina.home}/logs/localhost.log
log4j.appender.LOCALHOST.MaxFileSize=10MB
log4j.appender.LOCALHOST.MaxBackupIndex=5
log4j.appender.LOCALHOST.layout=org.apache.log4j.PatternLayout
log4j.appender.LOCALHOST.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} %p-%c{1}: [%m]%n
log4j.appender.LOCALHOST.Append=true
log4j.appender.LOCALHOST.Encoding=UTF-8
log4j.appender.MANAGER=org.apache.log4j.RollingFileAppender
log4j.appender.MANAGER.File=${catalina.home}/logs/manager.log
log4j.appender.MANAGER.MaxFileSize=10MB
log4j.appender.MANAGER.MaxBackupIndex=5
log4j.appender.MANAGER.layout=org.apache.log4j.PatternLayout
log4j.appender.MANAGER.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} %p-%c{1}: [%m]%n
log4j.appender.MANAGER.Append=true
log4j.appender.MANAGER.Encoding=UTF-8
log4j.appender.HOST-MANAGER=org.apache.log4j.RollingFileAppender
log4j.appender.HOST-MANAGER.File=${catalina.home}/logs/host-manager.log
log4j.appender.HOST-MANAGER.MaxFileSize=10MB
log4j.appender.HOST-MANAGER.MaxBackupIndex=5
log4j.appender.HOST-MANAGER.layout=org.apache.log4j.PatternLayout
log4j.appender.HOST-MANAGER.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} %p-%c{1}: [%m]%n
log4j.appender.HOST-MANAGER.Append=true
log4j.appender.HOST-MANAGER.Encoding=UTF-8
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Encoding=UTF-8
log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment