[logback-user] DBAppender and EJB managed transactions

Henning Diederichs grave1740 at googlemail.com
Tue Jan 31 16:39:11 CET 2012


Hi there,

I think I found out, why I couldn't log in database as I described in December.
I activated the status listener as mentioned in an earlier question
concerning DBAppender like this:

<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />

and got this exception from JBoss:
ERROR in ch.qos.logback.classic.db.DBAppender[myDBAppender] - problem
appending event java.sql.SQLException: You cannot set autocommit
during a managed transaction!
	at java.sql.SQLException: You cannot set autocommit during a managed
transaction!
 	at 	at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:878)
	at 	at org.jboss.jca.adapters.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:712)
 	at 	at ch.qos.logback.core.db.DBAppenderBase.append(DBAppenderBase.java:90)
 	at 	at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88)
	at 	at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:64)
	at 	at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:285)
 	at 	at ch.qos.logback.classic.Logger.callAppenders(Logger.java:272)
 	at 	at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:473)
 	at 	at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:427)
 	at 	at ch.qos.logback.classic.Logger.error(Logger.java:574)

The transaction is handled by the EJB container and cannot be managed
by DBAppenderBase line 90.

I also tested the DBAppender in a web project that only uses Servlets
and no EJBs. I could manage to log with the same log file.
Is this a known issue? There has to be a possibility to log to DB
without managing the transaction. Best if logback itself finds out, if
managing transactions manually is allowed or not.

Regards,

Henning


More information about the Logback-user mailing list