logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hadley Willan <HWil...@bunnings.com.au>
Subject RE: AdoNetAppender connection timeouts
Date Mon, 17 Nov 2008 05:16:26 GMT
Hi all,

 

I've done some testing by writing a small test app that loops through,
throws an ArgumentException, gets caught and logs the exception to
log4net.

My config has both a local file appender and an ADO Net appender.

There's an artificial Sleep for a second in the loop so that it doesn't
just race by.

I've placed a StopWatch around the log4net call and set ReconnectOnError
to true.

 

The behaviour I'm seeing is that the reconnect gets done every few
seconds.

At the end of the email is a section of my console output from the test.

I unplugged the network cable at around 20 and plugged it back in at 50
there was a total of 120 loops.

During the disconnection there's delays of up to 15s as a reconnection
attempt is made.

 

Two questions.

1.	Is it possible to specify how long to wait between reconnection
attempts? Eg.  DelayBetweenReconnectionSeconds="60"  eg, wait a minute
before trying to reconnect again.
2.	Given the delays, I'd say the reconnection attempt is a blocking
call... Is there any way this can be an asynchronous call that changes
the connected state flag if it succeeds? This would allow for a fast
return of the log attempt. Yes, the message being logged is lost, but it
doesn't halt the calling code and introduce delays into the application.


 

Thanks in advance.

Hadley

 

Timing[12] (6)ms

Timing[13] (3)ms

Timing[14] (10)ms

Timing[15] (3)ms

Timing[16] (3)ms

Timing[17] (6)ms

Timing[18] (3)ms

Timing[19] (8)ms

Timing[20] (9446)ms

Timing[21] (14830)ms

Timing[22] (14830)ms

Timing[23] (7)ms

Timing[24] (6)ms

Timing[25] (6)ms

Timing[26] (6)ms

Timing[27] (14830)ms

Timing[28] (6)ms

Timing[29] (6)ms

Timing[30] (6)ms

Timing[31] (6)ms

Timing[32] (6)ms

Timing[33] (6)ms

Timing[34] (6)ms

Timing[35] (6)ms

Timing[36] (6)ms

Timing[37] (14829)ms

Timing[38] (14830)ms

Timing[39] (14829)ms

Timing[40] (6)ms

Timing[41] (6)ms

Timing[42] (6)ms

Timing[43] (6)ms

Timing[44] (14829)ms

Timing[45] (14829)ms

Timing[46] (6)ms

Timing[47] (6)ms

Timing[48] (6)ms

Timing[49] (6)ms

Timing[50] (41554)ms

Timing[51] (8)ms

Timing[52] (3)ms

Timing[53] (3)ms

Timing[54] (3)ms

Timing[55] (3)ms

 

________________________________

From: Hadley Willan [mailto:HWillan@bunnings.com.au] 
Sent: Monday, 17 November 2008 09:48
To: Log4NET User
Subject: RE: AdoNetAppender connection timeouts

 

Actually,

 

I was just thinking about TCP timeouts and lockups to the caller.

Is the log4net logging done in a separate thread to the caller? 

 

If the connection to the DB goes away, it's good that it'll reconnect,
but during that connection time, how does log4net handle the timeout?

 

Thanks

Hadley

 

________________________________

From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Monday, 17 November 2008 00:55
To: Log4NET User
Subject: Re: AdoNetAppender connection timeouts

 

The AdoNetAppender keeps a reference to an open connection. At some
point it ensures the connection is open:

// shortened somewhat...the actual code is longer
if (m_reconnectOnError && m_dbConnection.State != ConnectionState.Open)
{
 LogLog.Debug("Attempting to reconnect to database...");
 InitializeDatabaseConnection();
 InitializeDatabaseCommand();
}

The AdoNetAppender is not async by default. If you're on SqlServer I'd
recommend taking a look at an appender that Ayende wrote:

https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk/rhino-
commons/Rhino.Commons/Logging/AsyncBulkInsertAppender.cs

whichs usess the SqlBulkCopy (very fast!) and background threads to
write log messages to the database. 

 

________________________________

From: Hadley Willan <HWillan@bunnings.com.au>
To: log4net-user@logging.apache.org
Sent: Friday, November 14, 2008 1:56:40 AM
Subject: AdoNetAppender connection timeouts

Hi peoples,

 

How does the ADO.Net appender handle intermittent connections?

 

I'm assuming that it's holding a connection open and appending?

I have <bufferSize value="0"> set to ensure an immediate call to a
stored proc for logging.

 

So basically, do I need to worry about whether or not my connection to
the other end exists?

Could the lack of a network connection translate to a pause in the app
when the log statement gets written? 

Or is all logging an asynchronous thread that doesn't affect the caller?

 

Thanks in advance.

Hadley

 

 

 

 

 


************************************************************************
Bunnings Legal Disclaimer:

1) This email is confidential and may contain legally privileged
information. If you are not the intended recipient, you must not
disclose or use the information contained in it. If you have received
this email in error, please notify us immediately by return email and
delete the document.

2) All emails sent to and sent from Bunnings Group Limited.
are scanned for content. Any material deemed to contain inappropriate
subject matter will be reported to the email administrator of all
parties concerned.
************************************************************************


************************************************************************
Bunnings Legal Disclaimer:

1) This email is confidential and may contain legally privileged
information. If you are not the intended recipient, you must not
disclose or use the information contained in it. If you have received
this email in error, please notify us immediately by return email and
delete the document.

2) All emails sent to and sent from Bunnings Group Limited.
are scanned for content. Any material deemed to contain inappropriate
subject matter will be reported to the email administrator of all
parties concerned.
************************************************************************


************************************************************************
Bunnings Legal Disclaimer:

1)     This email is confidential and may contain legally privileged
information.  If you are not the intended recipient, you must not
disclose or use the information contained in it.  If you have received
this email in error, please notify us immediately by return email and
delete the document.

2)     All emails sent to and sent from Bunnings Group Limited.
are scanned for content.  Any material deemed to contain inappropriate
subject matter will be reported to the email administrator of all
parties concerned.
************************************************************************
Mime
View raw message