主题:log4j.properties 的路径配置
如果log4j.properties配置文件不是放在WEB-INF\classes目录下,那么需要通过程序配置properties的路径。
需要执行类似下面配置代码:
String realPath=this.getServletContext().getRealPath(File.separator);
PropertyConfigurator.configure(realPath+"
\\WEB-INF\\classes\\com\\resources\\conf\\log4j.properties");
我把这段代码是放在servlet的init()函数里,这个servlet当然是自己重载的servlet.
类似如下:public class MyActionServlet extends ActionServlet
我在我的项目里就是这么用的,希望对你有帮助。