views:

62

answers:

1

I use log4j as logger for my web application. in log4j, I can set the level log in log4j properties or log4j.xml. in log4j, we instance logger as follows:

static Logger logger = Logger.getLogger(SomeClass.class);

I init log4j basic configurator in a servlet file using init method. But, I usually test application using JUnit, So I init the basic configurator in setup method. after that, I test the application, and I can see the log.

Because I deployed, the web in websphere. I change all of logging instance become:

private Log log = LogFactory.getLog(Foo.class);

I don't know how to load basic configurator using ACL. so I can't control debug level to my JUnit test.

do you have any suggestion, without changing

static Logger logger = Logger.getLogger(SomeClass.class); 

become

static Logger logger = Logger.getLogger(SomeClass.class);
A: 

What logging system you use as backend for Apache Commons Logging in Websphere in your unit tests? ACL is just a wrapper for other logging backends (such as log4j), and you configure logging level using backends configuration facilities.

So I think you should just use log4j in your unit tests and use its basic configuration in setup methods.

Juha Syrjälä
I just use ACL in my component. private Log log = LogFactory.getLog(Foo.class);, If I use log4j for basic configuration in my setup method. I must change private Log log = LogFactory.getLog(Foo.class); for every class that I have developed become static Logger logger = Logger.getLogger(SomeClass.class);. that's I want to avoid for
adisembiring
ACL delegates logging to some other logging framework, if you are not using anything specifically, then it probably goes to java.util.logging. Configure that in your tests.
Juha Syrjälä