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 20:07:38 GMT
After looking at your code and the AdoNetAppender class, you seem to
have things setup correctly. I suggested the FastDbAppender class
mainly becuase it doesn't include any reference to transactions
whatsoever. I figured it your code worked with that appender, then
there's something wrong with AdoNetAppender. 

If you're comfortable building log4net (not too difficult...just open
the solution file and click Build), you may want to add additional log
statements around AdoNetAppender's SendBuffer method to verify that
m_dbCommand's Transaction property is really null. You might also want
to try outputing the value of:

 System.EnterpriseServices.ContextUtil.IsInTransaction

I don't know why that would be true considering AdoNetAppender doesn't
use anything from the System.EnterpriseServices namespace.

That's about my limit of my knowledge in terms of debugging distributed
transactions. These links may or may not help. It sounds like you
already have a good grasp on distributed transactions:

http://tinyurl.com/dtre7
http://cvs.neo.codehaus.org/neo/src/Neo/Core.Transactions/

http://tinyurl.com/8hqts
http://svn.apache.org/repos/asf/ibatis/trunk/cs/mapper/IBatisNet.Common/Transaction/

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

> I'm looking at the FastDbAppender now, and I'm not sure I understand
> what
> makes it different from the AdoNetAppender.  I see that it doesn't
> derive
> from AppenderSkeleton, and uses a hard-coded table structure.  But
> how does
> that not use transactions?  I thought by setting the UseTransactions
> property to 'false', the AdoNetAppender wouldn't use transactions. 
> Is that
> not necessarily the case?
> 
> Thanks,
> Mike
> 
> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
> Sent: Thursday, September 01, 2005 2:53 PM
> To: Log4NET User
> Subject: RE: Transactions and AdoNetAppender
> 
> 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:
> 
>  http://www.yousendit.com/
> 
> 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:
> 
> http://tinyurl.com/7unou
>
http://cvs.apache.org/viewcvs.cgi/logging-log4net/examples/net/1.0/Appenders
> /SampleAppendersApp/cs/src/Appender/
> 
> --- "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.
> > 
> > 
> 
> 


Mime
View raw message