문제

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