📄 log4jinit.java
字号:
/*
* 创建日期 2005-9-1
*/
package com.common.util;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import org.apache.log4j.PropertyConfigurator;
/**
* 初始化Log4j日志文件
* @author 李伟光
*/
public class Log4jInit extends HttpServlet {
/**
* 服务器启动时初始化Log4j环境
*/
public void init() throws ServletException {
String prefix = getServletContext().getRealPath("/");
String file = getInitParameter("log4j");
// if the log4j-init-file is not set, then no point in trying
if(file != null) {
PropertyConfigurator.configure(prefix+file);
System.out.println("Log4jInit:"+prefix+file);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -