Eclipse下log4j的配置问题
已经在工程中添加了外部log4j-1.2.9.jar文件,但运行后提示说找不到log4j.properties文件,可我以把log4j.properties放到了WEB-INF下了,而且web.xml配置也应该没问题,为什么会找不到,请各位指点,谢谢。具体文件如下:
servlet文件:
package com.mylog;
import javax.servlet.*;
import java.io.*;
import javax.servlet.http.*;
import java.sql.*;
import org.apache.log4j.*;
public class DBExceptionServlet extends HttpServlet
{
static Logger logger=Logger.getRootLogger();
static Logger bookLogger=Logger.getLogger( "bookstoreLogger ");
public void init() throws
ServletException {
String prefix=getServletContext().getRealPath( "/ ");
String file=getInitParameter( "log4j-init-file ");
if(file!=null){
PropertyConfigurator.configure(prefix=file);
}
try
{
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");
}
catch(
ClassNotFoundException ce)
{
throw new
UnavailableException( "加载数据库驱动失败! ");
}
}
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,
IOException {
Connection conn=null;
Statement stmt=null;
try
{
conn=DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;databasename=pubs ", "sa ", "winsun1234 ");
stmt=conn.createStatement();
stmt.executeUpdate( "delete from jobs wh