Seeing errors or warnings in catalina.out about log4j

Article ID:205320530
1 minute readKnowledge base

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
This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.