首页 > 代码库 > log
log
<servlet> <servlet-name>log4jInit</servlet-name> <servlet-class>com.isoftstone.servlet.Log4JInit</servlet-class> <init-param> <param-name>log4j-config-file</param-name> <param-value>/WEB-INF/classes/conf/log4j.properties</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> package com.isoftstone.servlet; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import org.apache.log4j.*; /** * log4jInit load * @author King * @time 2014-09-23 */ public class Log4JInit extends HttpServlet { public void init() throws ServletException { String prefix = getServletContext().getRealPath("/"); String webappHome = getServletContext().getRealPath(""); System.setProperty("webappHome", webappHome); String file = getServletConfig().getInitParameter("log4j-config-file"); System.out.println("loading log4j>>>>>>>>>>>>>>>>>>>>"+prefix + file); // 从Servlet参数读取log4j的配置文件 if (file != null) { PropertyConfigurator.configure(prefix + file); } } public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { } }
log
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。