Bug 46983 - More Debug output for log4j auto-configure requested
More Debug output for log4j auto-configure requested
Status: NEW
Product: Log4j
Classification: Unclassified
Component: Configurator
unspecified
All All
: P2 enhancement
: ---
Assigned To: log4j-dev
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2009-04-07 07:40 UTC by Dan Armbrust
Modified: 2009-04-07 07:40 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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