[logback-user] LogBack JNDIConnectionSource

Alphy binnyal at gmail.com
Thu May 26 04:55:28 CEST 2011


I am using JNDIConnectionSource for writing logs to my postgres DB .But I am
facing a problem in transaction handling .

App Server : Glassfish.

In EJB , I have Stateteless Session Bean and I have
private static final Logger auditlog = LoggerFactory.getLogger("audit");

Inside I have method for transactions.

Bean{
Method(){
Method1();
Method2();
auditlog.info("method");
}
Method1()
{
em.persist();
auditlog.info("method1");

}
Method2()
{
em.persist();
auditlog.info("method2");

}
}

<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
<connectionSource class="ch.qos.logback.core.db.JNDIConnectionSource">
 
   </connectionSource>
 </appender>

I wanted Method1 and Method 2 in one transaction and if any failure need to
rollback both. Earlier when I was writing logs to file it was working fine
and now when I changed to Db, I realised the call to write logs is closing
existing transaction and starting new transaction to write to DB. Please let
me know how I can use the same transaction for writing to logs. I am using
same connection pool for both logging and application.
-- 
View this message in context: http://old.nabble.com/LogBack--JNDIConnectionSource-tp31704423p31704423.html
Sent from the Logback User mailing list archive at Nabble.com.



More information about the Logback-user mailing list