我在OS X Yosemite和JRE8上,我似乎无法将日志记录到数据库以使用log4j,是否有人有此解决方案?
log4j:错误无法加载驱动程序
java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1295)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1147)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:260)
at org.apache.log4j.jdbc.JDBCAppender.setDriver(JDBCAppender.java:391)
at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:248)
at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:215)
at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:289)
at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:186)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.error(Category.java:322)
答案 0 :(得分:1)
如果您使用的是Java 8,则无法使用JDBC-ODBC Bridge,因为它已被删除。需要用commons-logging-1.1.3.jar