📄 initlog4j.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -