Seeing errors or warnings in catalina.out about log4j

Issue

Warnings appear in tomcat/logs/catalina.out about log4j, such as:

log4j:WARN No appenders could be found for logger (net.bull.javamelody).
log4j:WARN Please initialize the log4j system properly.

Environment

  • CloudBees Jenkins Enterprise
  • Apache Tomcat container

Resolution

You just need to properly configure log4j.properties or log4j.xml. One of these files should exist in /WEB-INF/classes. If not create them.

Navigate here to the section Configuration to see what to include in this file: Apache log4j manual

One of the examples from that link for log4j.properties file:

# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.