日期:2014-05-17  浏览次数:20782 次

log4j配置文件启动项目报错。
属性文件配置如下:
XML code
log4j.rootLogger=INFO,db   
log4j.appender.db=org.apache.log4j.jdbc.JDBCAppender   
log4j.appender.db.BufferSize=10      
log4j.appender.db.driver=net.sourceforge.jtds.jdbc.Driver                      
log4j.appender.db.URL=jdbc:jtds:sqlserver://server:1434/pcbsyn 
log4j.appender.db.user=sa  
log4j.appender.db.password=711  
log4j.appender.db.sql=insert into logInfo(userId,userName,lclass,lmethod,lTime,llevel,message) values ('%X{userId}','%X{userName}','%C','%M','%d{yyyy-MM-dd HH:mm:ss}','%p','%m')  
  
log4j.appender.db.layout=org.apache.log4j.PatternLayout  


端口是1434 数据库是pcbsyn 。这个jtds的jar文件 在WEB-INF\lib目录下面是存在的! jtds-1.2.5.jar
数据库是 sql server 2000 sp4

Java code
log4j:ERROR Failed to load driver
java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver                      
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at org.apache.log4j.jdbc.JDBCAppender.setDriver(JDBCAppender.java:351)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:206)
    at org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:165)
    at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:130)
    at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:97)
    at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:689)
    at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647)
    at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:544)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:440)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:476)
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471)
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:125)
    at org.apache.log4j.Logger.getLogger(Logger.java:105)
    at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:289)
    at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:109)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1116)
    at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:914)
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:604)
    at org