tags:

views:

238

answers:

1

Hi folks,

I'm using log4Net for my logging. I also have the following set...

<log4net debug="true"> .. </>

Ok, now, when i have the following code

log4net.Config.BasicConfigurator.Configure();

I don't really get any verbose internal-debug info but I do get displayed anything I log.

Now, when i swap that code out and replace it with this:

log4net.Config.XmlConfigurator.Configure();

I get a lot of internal-debug xml info and anything I log, gets displayed.

So why is this? what's the difference between the two?

+2  A: 

BasicConfigurator only allows one appender to be configured, at the root, and it can only log to the console. It doesn't really give you any debug info because there isn't really any debug info.

XmlConfigurator gives you the full set of log4net configuration options - see the Configuration section of the manual for details. It actually starts with an example using BasicConfigurator and proceeds to show you all of the additional properties you can set in the XML.

In a production application you'll probably want to have different loggers with different appenders using different thresholds and areas; you'll probably be receiving log information from several different components and don't want to do exactly the same logging for each one. You'll also definitely want to log to places other than the console - log files, event log, e-mail alerts, that sort of thing. You can only do this with the XmlConfigurator.

Aaronaught
Pure.Krome