For the rootCategory definitions, whitespace characters between the log level and the comma before log type causes the default log level to be used (DEBUG) > log4j.rootCategory=INFO , FILE For the above rootCategory definition, the logger uses DEBUG as default for the log level. This is because the method "public static Level toLevel(String sArg, Level defaultLevel)" in the org.apache.log4j.Level class does not trim the level string. Therefore from the above definition of rootCatetory the string "INFO " is passed to the toLevel method. Which does not match any of the criteria in the toLevel method. A simple trim of the whitespace in the toLevel method would solve this issue. /** Convert the string passed as argument to a level. If the conversion fails, then this method returns the value of <code>defaultLevel</code>. */ public static Level toLevel(String sArg, Level defaultLevel) { if(sArg == null) return defaultLevel; String s = sArg.toUpperCase(); if(s.equals("ALL")) return Level.ALL; if(s.equals("DEBUG")) return Level.DEBUG; if(s.equals("INFO")) return Level.INFO; if(s.equals("WARN")) return Level.WARN; if(s.equals("ERROR")) return Level.ERROR; if(s.equals("FATAL")) return Level.FATAL; if(s.equals("OFF")) return Level.OFF; if(s.equals("TRACE")) return Level.TRACE; return defaultLevel; }
Now that we support TRACE, we should also decide if we should change the default (fallback) level to TRACE.
Added a String.trim() in the implementation of OptionConverter.toLevel() which should address the issue in PropertyConfigurators. Whether TRACE should be used as default if level is unrecognized is a distinct issue. I think it should stick the way that it is, but if you disagree, log a new bug request. Committed in rev 439043 and 439044 (trunk and 1.2 branch, respectively).