logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject RE: Transactions and AdoNetAppender
Date Thu, 01 Sep 2005 18:52:31 GMT
You could host the file on a friend's website, your company's website
for a few days, or use a free service like this:


Is the class really that large that it needs to be a .ZIP file? Can you
condense your working example down into one or two small text files and
attach those?

The FastDbAppender appender doesn't use transactions:


--- "Michael S. Collier" <michael.collier@centricconsulting.com> wrote:

> First, thanks for the help.
> I'm not sure I totally understand what you're telling me.
> I've worked up a sample application that basically does what I'm
> trying to
> do in my real application.  I would post it, but apparently the
> mailing list
> doesn't let me post ZIP files.  Any ideas how to get around this?
> Thanks,
> Mike
> -----Original Message-----
> From: Aaron Morton [mailto:log4net@the-mortons.org] 
> Sent: Thursday, September 01, 2005 9:52 AM
> To: Log4NET User
> Subject: Re: Transactions and AdoNetAppender
> Michael.
> Could it be that another part of your app is witting a log message 
> before MethodA ? Or that log4net is been initialized by a component
> that 
> has a different transactions attribute value.
> If so this could be the reason the thin wrapper did not work. As the
> ADO 
> appender caches it connection for a while, perhaps the connection is 
> been associated with the Transactions property of the object that
> caused 
> it to be created. This is just a wild theory, you could test it with 
> your thin wrapper class making sure log4net is not initialised or
> called 
> by another part of the app.
> let me know if this makes sense. If your still having problems let me
> know, if you have some sample code that would be handy.
> thanks
> aaron
> ---
> 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
> 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