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?

有帮助吗?

解决方案

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?)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top