Ask Basic Configurator in Apache Commong Log
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 log开发者_如何学编程ger = Logger.getLogger(SomeClass.class);
become
static Logger logger = Logger.getLogger(SomeClass.class);
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.
精彩评论