如何禁用 log4net 捕获所有异常?

How to disable log4net from catching all exceptions?

我想实现在记录特定文本时抛出异常的假 appender。 显然使用 log4net 是非常困难的。 我试图实现我自己的 Appender 派生自 AppenderSkeleton。 还将 ErrorHandler 更改为重新抛出异常的一个。但是没有什么能阻止 log4net 捕获所有异常。

有没有办法阻止 log4net 这样做?最好以编程方式。

谢谢

你不能这样做。 Log4net 没有设计抛出异常。按照设计,log4net 不与 运行 程序交互。

Is log4net a reliable logging system? No. log4net is not reliable. It is a best-effort and fail-stop logging system. By fail-stop, we mean that log4net will not throw unexpected exceptions at run-time potentially causing your application to crash. If for any reason, log4net throws an uncaught exception (except for ArgumentException and ArgumentNullException which may be thrown), please send an email to the log4net-user@logging.apache.org mailing list. Uncaught exceptions are handled as serious bugs requiring immediate attention. Moreover, log4net will not revert to System.Console.Out or System.Console.Error when its designated output stream is not opened, is not writable or becomes full. This avoids corrupting an otherwise working program by flooding the user's terminal because logging fails. However, log4net will output a single message to System.Console.Error and System.Diagnostics.Trace indicating that logging can not be performed.