Question

I've been searching, but not finding, so I thought I'd ask.

When using a log4net appender that buffers, do I need to call some kind of flush on application exit or does log4net take care of that itself?

Was it helpful?

Solution

You can check the source code at http://svn.apache.org/repos/asf/logging/log4net/trunk/src/log4net/Appender/

But basically, as I understand it, if your program closes down correctly, then the appenders should be flushed.

AdoNetAppender inherits from BufferingAppenderSkeleton which inherits from AppenderSkeleton and so the finalizer on class AppenderSkeleton will call Close() on your AdoNetAppender which calls base.Close() and the base class is BufferingAppenderSkeleton and this methods calls Flush().

Of course, there are times when your finalizer does not run (See Are .net finalizers always executed?)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top