开发者

xmlconfigurator.configure not throwing exceptions

I am trying to configure log4net for an application.

System.IO.FileInfo fi = new System.IO.FileInfo("some junk file name");
log4net.Config.XmlConfigurator.Configure(fi);
log4net.Config.XmlConfigurator.ConfigureAndWatch(fi);

I got surprised, when above code is not throwing any exception !!!!

when file doesn't exists , why lo开发者_开发问答g4net is not throwing any exception ? Isn't it bad design ? Is there any reason behind designing such behaviour ??????

If it is not throwing any exception , how can i know, the file is parsed successful and working properly ?


I believe this is deliberate: look at the section "Is Log4Net a reliable logging system" in the Log4Net FAQ.

The idea is that a logging subsystem should not throw exceptions causing your application to crash simply because of a bug or configuration error within the logging subsystem.

As for validating your configuration file, you can test that a configuration file produces the expected output in a development environment before deploying to production. Don't modify production configuration files except with tested tools (no manual editing).

Also I understand that you can add an attribute "debug=true" to the log4net element to enable internal log4net debugging. Though you'd presumably need at least one appender to be configured correctly to see the internal debugging output. I've never tried this though.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜