logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Walden H. Leverich" <Wald...@TechSoftInc.com>
Subject RE: batching log entries until exception
Date Tue, 27 Nov 2007 17:44:14 GMT
> Writing log events to an appender is usually a slower process than
generating them 
>so there shouldn't be much overhead with capturing messages then
ignoring them.

Generally true, but I know we have some uses of IsDebugEnabled that
wrapper debug statements that are "expensive" including reflection. 

Still a nice idea to have the debug-level info only when needed. What I
wouldn't give for a lower-than-debug logging level. :)

-Walden

-- 
Walden H Leverich III
Tech Software
(516) 627-3800 x3051
WaldenL@TechSoftInc.com
http://www.TechSoftInc.com

Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)


-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Tuesday, November 27, 2007 12:40 PM
To: Log4NET User
Subject: Re: batching log entries until exception

You could store a list or CyclicBuffer in the HttpContext then write an
HttpModule that flushes the events when appropriate. If you use a
CyclicBuffer you can set it so the message count doesn't exceed a
certain number. I recall there being some discussion about writing code
that would capture the last 500 DEBUG messages and only send them to an
appender if an exception occurred. If no exception occurred, the
messages would be destroyed when the HttpContext is disposed. NLog has
such a target:

 http://www.nlog-project.org/target.ASPNetBufferingWrapper.html

One implementation might call for an appender to be aware that it will
be used in the context of an ASP.Net website and will eventually forward
its contents to another appender:

 public class HttpContextBufferingForwardingAppender :
BufferingForwardingAppender, IHttpModule
 {
   // TODO: buffer items in HttpContext, flush when the
HttpApplication's Error event is raised
 }

Writing log events to an appender is usually a slower process than
generating them so there shouldn't be much overhead with capturing
messages then ignoring them.

----- Original Message ----
From: David Bicking <David.Bicking@thehartford.com>
To: log4net-user@logging.apache.org
Sent: Tuesday, November 27, 2007 9:37:07 AM
Subject: batching log entries until exception



Hello,

I searched the list for this information, but I think my use case is a
 bit
obscure.  I am researching Log4Net as a possible plug-in logger for our
software.  We would like to have or create an unusual feature.  

We would like to collect log entries in memory during a discrete scope.
  In
our case, this would be an ASP.NET request.  We want to hold onto these
 logs
in memory until either the request completes or an exception occurs.
  We
want to output all the batched logs if an exception occurs, and discard
 the
ones that don't pass the normal filters if there were no errors.  

Has anyone done something like this with Log4Net?  Do you have
 suggestions
on how I might implement this using Log4Net?

--
David Bicking
-- 
View this message in context:
 
http://www.nabble.com/batching-log-entries-until-exception-tf4882083.htm
l#a13971789
Sent from the Log4net - Users mailing list archive at Nabble.com.





Mime
View raw message