Bug 46983

Summary: More Debug output for log4j auto-configure requested
Product: Log4j - Now in Jira Reporter: Dan Armbrust <daniel.armbrust.list>
Component: ConfiguratorAssignee: log4j-dev <log4j-dev>
Status: NEW ---    
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Dan Armbrust 2009-04-07 07:40:24 UTC
I recently spent a too much time trying to figure out why I was getting log4j "no appenders found" warning messages out of some of my webapps - even though my webapps dynamically configure log4j.

In the end, the problem was some of my third party jar files were trying to log something earlier in the startup sequence than when my dynamic log4j configuration occurred.

What should have been happening was log4j should have found my bootstrap log4j.properties file, and used that until my "real" configuration happened.  But in some cases, it wasn't - and even with log4j in full debug mode, I wasn't seeing why.

It turned out that another webapp was setting this system variable:  log4j.defaultInitOverride=true - which globally disabled auto configure for every webapp on the server.

I would like to suggest the following change to the static init block in LogManager.java:

// if there is no default init override, then get the resource
// specified by the user or the default config file.
if(override == null || "false".equalsIgnoreCase(override)) {

<autoconfigure stuff>

}
//NEW CODE
else if (LogLog.debugEnabled)
{
    LogLog.debug("Not autoconfiguring log4j because the system variable " + DEFAULT_INIT_OVERRIDE_KEY + " is set.";
}
//END OF NEW CODE