logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael S. Collier" <michael.coll...@centricconsulting.com>
Subject Transactions and AdoNetAppender
Date Wed, 31 Aug 2005 19:16:08 GMT
I'm having a problem using AdoNetAppender without transactions.  I have a
.NET class that derives from ServicedComponent.  This class is used as a
Queued Component.  Everything about the Queued Component seems to be working
as expected.  The class is marked with the
[Transaction(TransactionOption.Required)] attribute.  In the method, let's
call it MethodA, some logic is performed and data is then written to the
database.  If there is an exception, the exception is caught and Log4Net is
used to log the exception.  The AutoComplete attribute is set on MethodA to
force a rollback.  Log4Net is configured to write to a database via the
AdoNetAppender and to the local file system.  My problem is that the
exception data is not being written to the database.  I can see the
exception data in my log file though.


Using DebugView I see the following exception from Log4Net when I try to log
the exception data:


log4net:ERROR [AdoNetAppender] Failed in DoAppend 

System.Data.SqlClient.SqlException: Distributed transaction completed.
Either enlist this session in a new transaction or the NULL transaction. 

    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream) 

    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() 

    at log4net.Appender.AdoNetAppender.SendBuffer(IDbTransaction dbTran,
LoggingEvent[] events) 

    at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events) 

    at log4net.Appender.BufferingAppenderSkeleton.Append(LoggingEvent

    at log4net.Appender.AppenderSkeleton.DoAppend(LoggingEvent loggingEvent)


I have set the UseTransactions property to 'false' on the AdoNetAppender.
That didn't seem to help.  I have also tried making a thin wrapper class
around Log4Net, and marking that class with
[Transaction(TransactionOption.NotSupported)].  That didn't help either.


I'm really confused as to why there appears to be a transaction when I'm
using Log4Net.  To prove this I added another method to my thin wrapper
class that executes the same stored procedure I've configured the
AdoNetAppender to use.  Doing that worked.  So, I'm pretty sure that somehow
Log4Net is still using a transaction.


Any help on how to solve this problem would be greatly appreciated.


I'm running .NET 1.1 on Windows XP Pro SP2.

View raw message