initlog4j.java
来自「Log4j日志记录」· Java 代码 · 共 19 行
JAVA
19 行
package examples.net.log4j;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import org.apache.log4j.PropertyConfigurator;
public class InitLog4j extends HttpServlet{
public void init() throws ServletException {
String path = getServletContext().getRealPath("/");
//getInitParameter("propfile")方法从web.xml文件中读取Log4J配置文件的名字"profile"。
String propfile = path + getInitParameter("propfile");
PropertyConfigurator.configure(propfile);
//PropertyConfigurator.configure("F:/KingKwong/Log4j-test/web/ppts/log4j.properties");
//System.out.println("Connection Success!");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?