有人有这两方面的经验吗?它们之间有什么不同?
我们计划使用其中一个来登录企业应用程序。
引用:
log4net
nlog
编辑:我们对nlog或log4net没有现有的依赖关系。
有人有这两方面的经验吗?它们之间有什么不同?
我们计划使用其中一个来登录企业应用程序。
引用:
log4net
nlog
编辑:我们对nlog或log4net没有现有的依赖关系。
当前回答
对我们来说,关键的区别在于整体表现……
看看Logger。与Log4Net相比,NLog中的IsDebugEnabled,从我们的测试来看,NLog的开销更少,这就是我们所追求的(低延迟的东西)。
干杯, 弗洛里安
其他回答
首先查看堆栈的其余部分。
如果你正在使用NHibernate,它直接利用Log4Net。 其他框架可能有它们需要的其他特定的记录器。
除此之外:两者都很好。
我自己选择了Log4Net。配置起来很麻烦,如果配置不正确,找出哪里出了问题也很麻烦。但是,您可以让它做几乎任何您想从日志记录器。
如果你对Log4Net没有长期的问题,这是我写的一篇关于如何开始使用Log4Net的文章: http://elegantcode.com/2007/12/07/getting-started-with-log4net/
由于最近使用过这两个框架,我想我可以分享一下我对这两个框架的看法。
我被要求评估现有web应用程序的日志框架,在浏览了各种在线论坛后,我将选择范围缩小到NLog (v2.0)和log4net (v1.2.11)。以下是我的发现:
Setting/starting up with NLog is dead easy. You go through the Getting started tutorial on their website and you are done. You get a fair idea, how thing might be with nlog. Config file is so intuitive that anyone can understand the config. For example: if you want to set the internal logging on, you set the flag in Nlog config file's header node, which is where you would expect it to be. In log4net, you set different flags in web.config's appSettings section. In log4net, internal logging doesnt output timestamp which is annoying. In Nlog, you get a nice log with timestamps. I found it very useful in my evaluations. Filters in log4net - You better check my this question - log4net filter - how to write AND filter to ignore log messages and if you find an answer/solution for this, please let me know. I understand, there is a workaround for this question, as you can write your own custom filter. But something which is not easily available in log4net. Performance - I logged around 3000 log messages to database using a stored procedure. I used simple for loop (int i=0; i<3000; i++... to log the same message 3000 times. For the writes: log4net AdoAppender took almost double the time than NLog. Log4net doesnt support asynchronous appender.
经过比较,我选择了NLog作为日志框架。:)
我赞同上面的方法,并且更喜欢nLog。Entlib不必要地膨胀。
有一件事总是让我与Log4net忘记添加以下到全局。Asax初始化组件:
log4net.Config.XmlConfigurator.Configure();
根据我的经验,SmartInspect优于NLog和log4net。
它非常容易使用,文档很棒,您可以使用交互式日志查看器查看和过滤以前记录的消息,这是一个巨大的现实优势。
我喜欢的一件事是数据的标签视图,就像Chrome中的浏览器标签。每个选项卡都可以提供不同的日志过滤视图。
嗯. .我使用Enterprise库执行数据库日志记录任务 现在由于性能瓶颈,我切换到NLog。
一些比较信息:
http://pauliusraila.blogspot.com/2010/10/solving-database-logging-bottlenecks.html