读书人

知识点拾掇之Web项目中Log4J的初始化

发布时间: 2012-06-30 17:20:12 作者: rapoo

知识点整理之Web项目中Log4J的初始化

首先在web.xml中定义一个servlet,执行初始化

public void init(ServletConfig config) throws ServletException {    String prefix = config.getServletContext().getRealPath("/");    // Log4J    String log4jFile = config.getInitParameter("log4j");    String log4jConfigPath = prefix + log4jFile;    PropertyConfigurator.configure(log4jConfigPath);}
?

读书人网 >Web前端

热点推荐