问一个在Action中使用Log4j的问题..
很奇怪...我在MAIN()中可以用LOG4J,,
在EXECUTE里使用却没有反应..代码如下:
public class IndexAction extends BaseAction {
static Logger logger = Logger.getLogger(IndexAction.class.getName());
static{
PropertyConfigurator.configure( "Log4j.properties ");
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//......................
IndexAction.logger.info( "员工 " + memberId + "登录!!! ");
//.........................
}
public static void main( String args [] ){
//PropertyConfigurator.configure( "Log4j.properties ");
logger.info( "main ");
}
------解决方案--------------------在Action中,是不需要这一句的:
static{
PropertyConfigurator.configure( "Log4j.properties ");
}
系统会自动地去读取,classes下的log4j.properties文件.
注意 "log4j "的大小写,你把 "L "改为小写的试一下
------解决方案--------------------IndexAction.logger.info( "员工 " + memberId + "登录!!! ");
---->
logger.info( "员工 " + memberId + "登录!!! ");
试试吧,还没有象LZ那样用过.呵呵...
------解决方案--------------------没玩过