log4j数据库日志插入异常解决方案。

原创 2015年11月18日 09:01:03
2015-11-18 08:56:08,486 ERROR Unable to write to database [jdbcManager{ description=databaseAppender, bufferSize=0, connectionSource=factory{ public static java.sql.Connection haige.sat.util.ConnectionFactory.getDatabaseConnection() }, tableName=logs, columns=[ { name=date, layout=%d{yyyy-MM-dd HH:mm:ss}, literal=null, timestamp=false }, { name=level, layout=%level, literal=null, timestamp=false }, { name=message, layout=%message, literal=null, timestamp=false } ] }] for appender [databaseAppender]. org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to commit transaction logging event or flushing buffer.
    at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.commitAndClose(JdbcDatabaseManager.java:142)
    at org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager.write(AbstractDatabaseManager.java:166)
    at org.apache.logging.log4j.core.appender.db.AbstractDatabaseAppender.append(AbstractDatabaseAppender.java:103)
    at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:97)
    at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:428)
    at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:407)
    at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:365)
    at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:112)
    at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:1336)
    at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1325)
    at org.apache.logging.log4j.spi.AbstractLogger.info(AbstractLogger.java:907)
    at haige.sat.listener.HostInfoChecker.checkMainHostService(HostInfoChecker.java:301)
    at haige.sat.listener.HostInfoChecker.run(HostInfoChecker.java:154)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.BatchUpdateException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
    at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2055)
    at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
    at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
    at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
    at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.commitAndClose(JdbcDatabaseManager.java:137)
    ... 13 more
Caused by: java.sql.SQLException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2825)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2459)
    at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2007)
    ... 17 more

2015-11-18 08:56:08,488 ERROR An exception occurred processing Appender databaseAppender org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to commit transaction logging event or flushing buffer.
    at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.commitAndClose(JdbcDatabaseManager.java:142)
    at org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager.write(AbstractDatabaseManager.java:166)
    at org.apache.logging.log4j.core.appender.db.AbstractDatabaseAppender.append(AbstractDatabaseAppender.java:103)
    at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:97)
    at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:428)
    at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:407)
    at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:365)
    at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:112)
    at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:1336)
    at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1325)
    at org.apache.logging.log4j.spi.AbstractLogger.info(AbstractLogger.java:907)
    at haige.sat.listener.HostInfoChecker.checkMainHostService(HostInfoChecker.java:301)
    at haige.sat.listener.HostInfoChecker.run(HostInfoChecker.java:154)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.BatchUpdateException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
    at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2055)
    at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
    at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
    at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
    at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.commitAndClose(JdbcDatabaseManager.java:137)

    ... 13 more


最近在工作中遇到jetty服务器启动时,数据库日志插入异常,在寻找了许多资料后发现是数据库的插入更新方式BINLOG_FORMAT = STATEMENT造成的,解决方案是在Mysql数据库命令行下 set GLOBAL binlog_format = "Mixed",但是每次重启机器后都要设置,不知道哪位大神有解决方案,分享一下

SpringBoot配置log4j2的JdbcAppender日志写入数据库,可定义哪些日志写入

SpringBoot配置log4j2的JdbcAppender日志写入数据库,可定义哪些日志需要写入数据库...

Log4j写入数据库详解

 log4j是一个优秀的开源日志记录项目,我们不仅可以对输出的日志的格式自定义,还可以自己定义日志输出的目的地,比如:屏幕,文本文件,数据库,甚至能通过socket输出。本节主要讲述如何将日志信息输入...

项目上传至服务器,配置都没有问题,但是数据无法插入数据库

#今天改了一个bbs的代码,想把它加入到自己的项目中去,在本地运行都没问题,但是上传到服务器上,注册信息无法插入数据库#  -分析 -自己项目那块在服务器上运行没有问题,增删改查都是可以的数据,证...

maven jar包冲突: cannot be cast to ch.qos.logback.classic.LoggerContext

问题:      折腾半天环境,终于能跑起来,可以我加了两个maven包之后,又起不来不了。报错如下: ClassCastException: org.slf4j.impl.Log4jLogger...
  • bohu83
  • bohu83
  • 2016年07月01日 10:18
  • 7699

Spring MVC 项目中配置log4j 出现错误log4j:ERROR Failed to excute sql

以下是log4j的配置文件log4j.properties的内容: log4j.rootLogger = debug,CONSOLE,DATABASE,LOGFILE # output...

MyBatis Log4j无法打印SQL语句问题详解

项目采用SpringMVC+Mybatis的架构,日志工具还是最常用的log4j,整合了其他框架之后,发现无法打印SQL语句,然而项目中的显示调用日志却可以正常打印出来,还有当SQL拼写有错误的时候会...

log4j2配置mybatis日志

前天我上传了我的MyBatis系列课程( http://edu.51cto.com/course/course_id-1110.html )的第六讲,主要内容是如何使用Log4j2(具体版本为v2.0...
  • tjeagle
  • tjeagle
  • 2015年05月06日 09:57
  • 1480

java.lang.NoClassDefFoundError org.apache.log4j.spi.ThrowableInformation

1. Problem Description: Our application has been working normal in past months, however, after our ...

java.sql.SQLException: ORA-00917: 缺少逗(log4j在数据库中插入相应信息时出现了此错误)

在用log4j在数据库中写的信息时出现了java.sql.SQLException: ORA-00917: 缺少逗号 错误,但在数据库中也插入进去数据了。log4j的内容为:log4j.rootLog...

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:log4j数据库日志插入异常解决方案。
举报原因:
原因补充:

(最多只允许输入30个字)