logback-1.0.13.jar
JDK 1.6u34を使用します。
次のJava Webアプリ(WAR)がありますWEB-INF/classes/logback.xml
:
<configuration debug="true" scan="true" scanPeriod="5 minutes">
<appender name="logManager-dbAppender" class="ch.qos.logback.classic.db.DBAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>NEUTRAL</onMismatch>
</filter>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>NEUTRAL</onMismatch>
</filter>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<connectionSource class="ch.qos.logback.core.db.JNDIConnectionSource">
<jndiLocation>java:comp/env/jdbc/dbLogging-local</jndiLocation>
</connectionSource>
</appender>
<root level="ALL">
<appender-ref ref="logManager-dbAppender" />
</root>
</configuration>
そして、以下(すべての Web アプリに対して${TOMCAT_HOME}/conf/context.xml
グローバル):context.xml
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource
name="jdbc/dbLogging-local"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://my-mysql-server.example.com:3306/my_db"
username="my_user"
password="my_password"
maxActive="20"
/>
</Context>
また、実行時のクラスパス ( ) に最新の MySQL/JDBC ドライバーWEB-INF/lib/mysql-jdbc-5.1.25.jar
をインストールします。さらに、これはグローバルであるため、 /libcontext.xml
にも同じ MySQL/JDBC ドライバーがあります。${TOMCAT_HOME}
そして、次のスタック トレースを取得しています。
08:54:52,905 |-ERROR in ch.qos.logback.classic.db.DBAppender[logManager-dbAppender] - problem appending event com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'caller_filename' cannot be null
at com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'caller_filename' cannot be null
at at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at at com.mysql.jdbc.Util.getInstance(Util.java:386)
at at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1040)
at at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
at at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
at at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)
at at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)
at at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at at ch.qos.logback.classic.db.DBAppender.subAppend(DBAppender.java:105)
at at ch.qos.logback.classic.db.DBAppender.subAppend(DBAppender.java:42)
at at ch.qos.logback.core.db.DBAppenderBase.append(DBAppenderBase.java:108)
at at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88)
at at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)
at at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:272)
at at ch.qos.logback.classic.Logger.callAppenders(Logger.java:259)
at at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:441)
at at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:395)
at at ch.qos.logback.classic.Logger.info(Logger.java:599)
at at com.myapp.server.DummyServlet.doGet(Unknown Source)
at at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at at java.lang.Thread.run(Thread.java:662)
MySQL の例外が発生する理由について何か考えはありますか? Old Nabble でこの同様の未回答の質問を見つけましたが、それが長年のバグであるかどうか疑問に思っています...?
logging_event.caller_filename
(Logback DBAppender の onw DDL に従って) その列で NULL が許可されていない場合、MySQL サーバーに接続して NULL を挿入しているようです。
前もって感謝します!