You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Robert Oxspring <ro...@imapmail.org> on 2003/02/22 17:16:31 UTC

[Logging] Where is my configuration coming from?

I'm trying to use Commons-Logging within an app and figured that it 
would be useful to turn on trace logging in a test case while doing some 
debugging.  To do this I put code along the lines of the following in 
the setUp() method of the testcase:
   
        
System.setProperty("org.apache.commons.logging.simplelog.log."+getName(),"trace");
        Log log =  new SimpleLog(getName());
        target.setLog(log);

But the logging output refuses to show anything below the default "info" 
level.  Investigating further I tried the following which works from a 
commandline invocation but still within the testcase nothing below 
"info" gets through.  The testcase itself is running within Ant's junit 
task and the results are the same with or without forking junit.

        
System.setProperty("org.apache.commons.logging.simplelog.defaultlog","trace");
        
System.setProperty("org.apache.commons.logging.simplelog.log.test","trace");
        
System.setProperty("org.apache.commons.logging.simplelog.showlogname","true");
        
System.setProperty("org.apache.commons.logging.simplelog.showShortLogname","true");
        
System.setProperty("org.apache.commons.logging.simplelog.showdatetime","true");
       
        SimpleLog log =  new SimpleLog("test");
        log.trace("tracing");
        log.debug("debugging");
        log.info("informing");
        log.warn("warning");
        log.error("erroring");
        log.fatal("fatalling");

So where is the configuration in use coming from? And how should I be 
configuring the log instance to work as I want it?

In case it matters I'm using JDK1.3.1_04, Ant 1.5.1,  Logging 1.0.2, and 
the following jars are being pulled into the classpath by ant.

ant.jar
junit.jar
optional.jar
xercesImpl.jar
xml-apis.jar

axiondb-M1-dev.jar
bcel.jar
commons-cli.jar
commons-collections.jar
commons-logging-api.jar
commons-logging.jar
graph.jar
hansel.jar
mailapi.jar
checkstyle-all.jar
junit.jar
quilt.jar
activation.jar
imap.jar
oe5dbx.jar
pop3.jar
smtp.jar

If you could CC me on any replies or move it over to commons-dev it 
would be appreciated.

Thanks in advance,

Rob


Re: [Logging] Where is my configuration coming from?

Posted by Rob Oxspring <ro...@imapmail.org>.
----- Original Message ----- 
From: "robert burrell donkin" <ro...@blueyonder.co.uk>
To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
Cc: "Robert Oxspring" <ro...@imapmail.org>
Sent: Tuesday, February 25, 2003 8:26 PM
Subject: Re: [Logging] Where is my configuration coming from?


> On Saturday, February 22, 2003, at 04:16 PM, Robert Oxspring wrote:
> 
> > I'm trying to use Commons-Logging within an app and figured that it would 
> > be useful to turn on trace logging in a test case while doing some 
> > debugging.  To do this I put code along the lines of the following in the 
> > setUp() method of the testcase:
> >          
> > System.setProperty("org.apache.commons.logging.simplelog.log."+getName(),"trace"
> > );
> >        Log log =  new SimpleLog(getName());
> >        target.setLog(log);
> >
> > But the logging output refuses to show anything below the default "info" 
> > level.
> 
> the following has worked for me in similar situations:
> 
>      SimpleLog log =  new SimpleLog(getName());
>      log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
>      target.setLog(log);
> 
> (i have a feeling that the default log level is set the first time that 
> any log is obtained and remains fixed.)
> 
> hope that this solves your problem.

It certainly does!  I hadn't noticed the setLevel() method before.

Thanks,

Rob

> 
> - robert
> 
> 
> 

Re: [Logging] Where is my configuration coming from?

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Saturday, February 22, 2003, at 04:16 PM, Robert Oxspring wrote:

> I'm trying to use Commons-Logging within an app and figured that it would 
> be useful to turn on trace logging in a test case while doing some 
> debugging.  To do this I put code along the lines of the following in the 
> setUp() method of the testcase:
>          
> System.setProperty("org.apache.commons.logging.simplelog.log."+getName(),"trace"
> );
>        Log log =  new SimpleLog(getName());
>        target.setLog(log);
>
> But the logging output refuses to show anything below the default "info" 
> level.

the following has worked for me in similar situations:

     SimpleLog log =  new SimpleLog(getName());
     log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
     target.setLog(log);

(i have a feeling that the default log level is set the first time that 
any log is obtained and remains fixed.)

hope that this solves your problem.

- robert