Re: AsyncAppender (was Re: Apache log4net Needs Help)

2016-11-04 Thread Stefan Bodewig
Hi Nicholas

On 2016-11-01, Nicholas Duane wrote:

> Got some questions around this.  I was hoping that if I put the call
> to LogManager.Shutdown() in my application it might call Close() on
> all the appenders.  However, that doesn't seem to be the case.

That's what I would have expected as well. This is code I've never
touched and I'm not familiar with the implementation choices back then,
but LogManager.Shutdown() leads to Logger.CloseNestedAppenders() which
only closes Appenders that are IAppenderAttachable.

I'm what to make from this myself.

> Not sure if the Flush() you talk about is something that might have
> solved my problem.

At least it is going to Flush all appenders.

> I checked over the links you provided.  One talks about implementing a
> queue in an async appender so that each developer wouldn't have to do
> it.  While that certainly sounds like a good thing to do, even this
> implementation would need to flush its queue, or at least do as much
> as it could in the time allotted, when the process shuts down.  That
> is the main point I'm trying to bring up as my appender has its own
> queue but the Close() method doesn't give me any significant amount of
> time to flush my queue and thus I'm losing events.

Ideas for a new implementation of the AsyncAppender are currently
discussed on the dev mailing list.

Stefan


Re: AsyncAppender (was Re: Apache log4net Needs Help)

2016-11-01 Thread Nicholas Duane
Got some questions around this.  I was hoping that if I put the call to 
LogManager.Shutdown() in my application it might call Close() on all the 
appenders.  However, that doesn't seem to be the case.  Not sure if the Flush() 
you talk about is something that might have solved my problem.


I checked over the links you provided.  One talks about implementing a queue in 
an async appender so that each developer wouldn't have to do it.  While that 
certainly sounds like a good thing to do, even this implementation would need 
to flush its queue, or at least do as much as it could in the time allotted, 
when the process shuts down.  That is the main point I'm trying to bring up as 
my appender has its own queue but the Close() method doesn't give me any 
significant amount of time to flush my queue and thus I'm losing events.


One of the links also provides an AsyncAppender implementation which the author 
claims will address the problem of lost events on shutdown, but it appears to 
use the Close() method to shutdown cleanly, which I would assume suffers from 
the same problem I experienced.  Namely, the Close() method appears to be 
called from log4net by way of syncing the .NET app domain shutdown event.  At 
that point you're not given any time to cleanup.


Thanks,

Nick


From: Stefan Bodewig <bode...@apache.org>
Sent: Sunday, October 16, 2016 7:32 AM
To: Log4NET User
Subject: AsyncAppender (was Re: Apache log4net Needs Help)

On 2016-10-16, Nicholas Duane wrote:

> By the way, what's the state of async appenders in log4net?

This is one of the things I'd love people to get involved in. We've got

* a simple implementation inside the sample
* https://issues.apache.org/jira/browse/LOG4NET-190
* https://issues.apache.org/jira/browse/LOG4NET-201
* https://issues.apache.org/jira/browse/LOG4NET-407

the later even made it into the 1.3 branch (that's now been
abandoned). It would be good if anybody found the time to make it work
inside the current trunk setup.

So there are few implementations. They may share the problem mentioned
here

> http://stackoverflow.com/questions/36344822/log4net-appenders-onclose-doesnt-seem-to-work

I haven't checked.

> Seems like log4net should not only expose a startup routine the app
> must call but also a shutdown routine, and indicate that it's
> essential it gets called.  Then log4net could shutdown the appenders
> in the shutdown routine as opposed to relying on .NET's appdomain
> shutdown logic.

There are Shutdown methods in LogManager and LoggerManager.

The patch Joe mentions that add Flush to certain appenders and to
LogManager has been added to svn trunk and will be part of 2.0.6 (which
will be the version of the next release).

Stefan


AsyncAppender (was Re: Apache log4net Needs Help)

2016-10-16 Thread Stefan Bodewig
On 2016-10-16, Nicholas Duane wrote:

> By the way, what's the state of async appenders in log4net?

This is one of the things I'd love people to get involved in. We've got

* a simple implementation inside the sample
* https://issues.apache.org/jira/browse/LOG4NET-190
* https://issues.apache.org/jira/browse/LOG4NET-201
* https://issues.apache.org/jira/browse/LOG4NET-407

the later even made it into the 1.3 branch (that's now been
abandoned). It would be good if anybody found the time to make it work
inside the current trunk setup.

So there are few implementations. They may share the problem mentioned
here

> http://stackoverflow.com/questions/36344822/log4net-appenders-onclose-doesnt-seem-to-work

I haven't checked.

> Seems like log4net should not only expose a startup routine the app
> must call but also a shutdown routine, and indicate that it's
> essential it gets called.  Then log4net could shutdown the appenders
> in the shutdown routine as opposed to relying on .NET's appdomain
> shutdown logic.

There are Shutdown methods in LogManager and LoggerManager.

The patch Joe mentions that add Flush to certain appenders and to
LogManager has been added to svn trunk and will be part of 2.0.6 (which
will be the version of the next release).

Stefan