有log4net.Config.BasicConfigurator.Configure()和log4net.Config.XmlConfigurator.Configure()之间的区别是什么?区别、

2023-09-04 12:23:29 作者:屋檐上

我用 log4net的我的日志记录。我也有下面的一组...

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

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

好了,现在,当我有以下的code

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.

现在,当我换了code出来,并用此代替:

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

log4net.Config.XmlConfigurator.Configure();

我得到了很多的内部调试XML信息,任何事情我登录,被显示出来。

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?

推荐答案

BasicConfigurator 只允许配置了一个附加器,在根,并且只能登录安慰。它并没有真正给你任何调试信息,因为那里的不是的任何真正的调试信息。

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 为您提供了全套log4net的配置选项 - 看的手册中的细节配置部分。它实际上是用一个例子开始使用 BasicConfigurator 并继续向你展示所有的附加属性,你可以在XML设置。

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.

在生产应用中,你可能会想有不同的记录器使用不同的阈值和地区不同的追加程序;你可能会从几个不同的组件接收日志信息,并不想这样做完全一样的日志记录每一个。你也肯定会想登录到该控制台的地方 - 日志文件,事件日志,电子邮件警报,诸如此类的事情。你只能做到这一点与 XmlConfigurator

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.

 
精彩推荐
图片推荐