commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Tarkenton <>
Subject [logging] [digester maybe?] Is this correct syntax for commons-logging?
Date Wed, 07 Jul 2004 16:00:18 GMT
Hello all.

I have a web app that uses Log4J.  I realize that commons-logging.jar 
just provides an interface on top of a logging implementation such as 
Log4J.  I am pretty sure that my commons-logging related syntax is what 
is preventing me from controlling logging.  You see, I am also using 
Apache Digester, and since Apache Digester uses commons-logging, it 
seems to be finding my configuration file, and 
automatically logging everything at the DEBUG level.  I assume it's just 
finding the root logger of Log4J, and not my "class level" logger.  I am 
trying to control that level of logging to only include ERROR level and 

I know this _sounds_ like a log4J problem, but I really believe I must 
be using commons-logging API incorrectly.  Take a look at my syntax for 
adding a logger to my Digester object:

public class TestResultsHandler implements MessageResourcesKeys {
    static final Logger logger = 
public static Digester initializeParser() {
        Digester digester = new Digester();
        digester.setLogger(new Log4JLogger(logger));
        digester.setErrorHandler(new TestResultsErrorHandler());

        // configure digester rules
        return digester;

public static void parse(String document) throws TestResultsException {
        Digester digester = initializeParser();

        TestResultsHandler resultsParser = null;
        try {
        //resultsParser = (TestResultsHandler)digester.parse(new 
        resultsParser =
        } catch (SAXParseException saxe) {
            String msg = 
            throw new TestResultsException(msg, saxe);
        } catch (SAXException saxe) {
            String msg = 
            throw new TestResultsException(msg, saxe);
        } catch (IOException ioe) {
            String msg = 
            throw new TestResultsException(msg, ioe);

Here are the contents of my file in WEB-INF\classes:

log4j.rootLogger=DEBUG, GuiAppender
# GuiAppender is set to be a FileAppender.

# PmA1 uses PatternLayout.
log4j.appender.GuiAppender.layout.ConversionPattern=%d: %-5p : %m%n

No matter what level I set the LEVEL for, I always 
get DEBUG messages which makes me believe the Digester is defaulting to 
the root logger of Log4J.  As a matter of fact, if I take out the code 
for setting the logger for the digester, it will still log at the DEBUG 
level.  This is why I think my use of the commons-logging api is 
incorrect.  I think perhaps I'm incorrectly setting the logger for the 
Digester object.  I have certainly named a logger, 
com.titan.bat.gui.testresults.TestResultsHandler in this properties 
file; is this not the same logger that is referenced as the static 
logger member of my TestResultsHandler class?

Thanks in advance for any insight you may be able to provide.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message