开发者

log4net - how to log a summary just before the logging system shutdown

I want to log some summary lines on domain shutdown, however log4net hooks the AppDomain.CurrentDomain.ProcessExit first and will shutdown the logging before I hav开发者_如何学运维e a chance to output my message. (And the message is never logged)

So my question is: 1. Is there a way to hook ProcessExit before log4net without playing too much with initialization order? (Certainly without changing the Program class of my application) 2. Does log4net provides any hook which it invokes just before shutdown?


The logger repositories (accessible with log4net.LogManager.GetAllRepositories()) have a event: ShutdownEvent. This is not useful for you since this event is raised after log4net shut down everything.

Hooking into AppDomain.CurrentDomain.ProcessExit worked quite fine for me. I just need to do that before I initialized log4net. (Not sure if that qualifies as "not playing too much with initialization order".)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜