import javax.servlet.http.HttpServlet; |
import org.apache.log4j.PropertyConfigurator; |
/** |
* 初始化Log4J |
* |
*/ |
public class Log4jInit extends HttpServlet { |
public void Init() { |
String filePath = getInitParameter( "log4j" ); |
System.out.println( "日志的配置文件路径为:" + filePath); |
if (filePath != null ) { |
PropertyConfigurator.configure(filePath); // 载入配置文件 |
System.out.println( "日志的配置文件读取成功" ); |
} |
} |
} |