tmenke tmenke - 1 month ago 15
Java Question

Minor loggers aren't logging with predefined RootLogger log level (log4j)

During runnig a multi-class java app with several dependencies (JARs), I got the problem that the minor loggers aren't logging on debug level even though the RootLoggers level is set to "ALL".

I want to illustriate the issue with following mwe, which works as intendet. Please note that the original app (which is more comprehensive) doesn't log on debug level, even though it should inherit the log level(ALL) from its root-logger. What might be the reason for the minor logger not logging at the same level as the root?


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j=""
debug = "true"
threshold = "all">

<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n"/>

<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="append" value="true"/>
<param name="file" value="out/Marktdaten_Uploader_Tool.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>

<level value="all"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender" />

Class1 (containing main method with root logger instantiation):

package log4j_Test;

import org.apache.log4j.*;

public class LoggerStart {

private static Logger logger = Logger.getRootLogger();

public static void main(String[] args) {


new Class2();


Class2 (Containing minor logger and command to log on debug level):

package log4j_Test;
import org.apache.log4j.Logger;

public class Class2
private static Logger logger = Logger.getLogger(Class2.class);

logger.debug("My debug message from Class2");

Answer Source

I fixed the issue due removing the log4j.xml at all and adding the logger config directly in the app's main method.