tags:

views:

169

answers:

1

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 log4net 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 ?

+2  A: 

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.

Joe