如何在log4net的记录停止接收事件 [英] How to receive events if log4net stops logging
问题描述
log4net的是在不引发错误有点太美好了。我想创建某种处理程序将触发如果log4net的无法启动或死亡,无法再登录。
Log4net is a little too good at not throwing errors. I am trying to create some kind of handler that fires if log4net can not start or dies and can no longer log.
我知道了应用程序设置键打开log4net的内部调试(log4net.Internal.Debug)的。我并不需要所有调试信息所有的时间虽然,只是如果没有与log4net的一个问题。
I am aware of the app settings key to turn on log4net's internal debugging (log4net.Internal.Debug). I don't need all the debugging information all the time though, just if there is an issue with log4net.
有没有人有他们编程捕捉的方式,并在log4net的处理的错误?
Does anyone have a way they have programmatically captured and handled errors in log4net?
推荐答案
那么,log4net的将使它很难为你做这个,因为它(设计)抑制这些记录操作过程中抛出的异常。这是因为当格式化日志信息生产系统不应该因为一个错误而失败。
Well, log4net will make it very hard for you to do this, since it will (by design) suppress exceptions which are thrown during logging operations. That's because a production system shouldn't fail because of an error while formatting a log message.
这是值得非常简单的图案布局尝试,因为有时它是运用% p {} XYZ图案布局造成的问题,如果相应的属性设置不正确的元素。如果一切正常,与一个简单的模式布局预期,你可以添加你需要回来一次的事情,看看你能找出问题的方式。
It's worth trying with very simple pattern layouts, as sometimes it's the use of %P{XYZ} elements in pattern layouts which cause problems if the corresponding properties are not properly set. If everything works as expected with a simple pattern layout, you can add the things you need back in one at a time and see if you can pinpoint the problem that way.
这篇关于如何在log4net的记录停止接收事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!