On 08/11/2007, at 2:18 AM, Phillip Mills wrote:

Thanks, I'll try.  I hadn't discovered that as an option.


actually the most efficient way is to get the LoggerRepository object and set that threshold to OFF. When deciding whether appenders get to see an event, the LoggerRepository's threshold is checked first, before the logger hierarchy is computed for levels.

Programitically it would be:

LogManager.getLoggerRepository().setThreshold(Level.OFF)


(Follow-up: Is there complete documentation or a DTD for log4j XML
configuration available?)

For the XML configuration stanza, it would look like this:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" threshold="OFF"
    xmlns:log4j="http://jakarta.apache.org/log4j/";>
....


Notice the threshold parameter? This would be useful in your environment because you could configure the log4j.xml file to specify everything you'd like to log _if_ logging was enabled (start with threshold=off) and then at runtime edit the file to activate the top level threshold to, say, DEBUG, allowing the actual logger levels defined in the xml config to be evaluated. You'd need to set up a FileWatchdog to monitor the log4j.xml so that when modified, log4j reconfigures itself.

The DTD and related docs are here:

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/DOMConfigurator.html

See the super class for most of the real information.

the dtd link seems broken from this page, but here's the link:

http://svn.apache.org/repos/asf/logging/log4j/trunk/src/main/resources/org/apache/log4j/xml/log4j.dtd

cheers,

Paul

Reply via email to