// import log4j packages import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; public class SetupServlet extends HttpServlet{
public void init(ServletConfig config) throws ServletException{
super.init(config);
// first thing to do, is to set up the Driver that we might be using // in case of JDBCAppender try{ Driver d = (Driver)(Class.forName( "org.gjt.mm.MySQL.Driver").newInstance()); DriverManager.registerDriver(d); //加载JDBC驱动程序,当预备将日志记录到数据库的时候可以使用 }catch(Exception e){ System.err.println(e); }
// next load up the properties //启动时从web.xml中获得配置文件的信息 String props = config.getInitParameter("props");
System.err.println( "ERROR: Cannot read the configuration file. " + "Please check the path of the config init param in web.xml"); throw new ServletException(); } }