码迷,mamicode.com
首页 > 其他好文 > 详细

log

时间:2017-06-14 02:12:41      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:efi   auth   pac   start   jin   int   set   str   tor   

 

    <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

标签:efi   auth   pac   start   jin   int   set   str   tor   

原文地址:http://www.cnblogs.com/bobo1713930654/p/7004041.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!