log4net与Nlog [英] log4net vs. Nlog

查看:518
本文介绍了log4net与Nlog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都有经验吗?他们如何相互对抗?

Anyone have experience for both? How do they stack up against each other?

我们正计划使用其中之一来登录企业应用程序.

We are planning on using one of them for logging in an enterprise application.

参考文献:

log4net

nlog

我们不存在对nlog或log4net的依赖.

We have no existing dependencies to either nlog or log4net.

推荐答案

我最近受命为即将进行的项目原型化一些登录".我没有任何日志记录框架的经验.我花了几天的时间在Log4Net,NLog和Enterprise Library上研究,浏览教程,制作玩具应用程序等. 3-4周后回来,将它们放到一个有凝聚力的演示中.希望其中一些对您有用.

I was recently tasked to "prototype up some loggin'" for an upcoming project. I didn't have any logging framework experience. I researched, ran through tutorials, made toy apps, etc. on Log4Net, NLog, and Enterprise Library for a few days. Came back 3-4 weeks later and put them together into a cohesive demo. Hopefully some of this is useful to you.

我对我们的项目的建议是:

My recommendation for our project is this:

  1. 使用日志记录外观(例如 Common.Logging
  1. Use a logging facade (e.g. Common.Logging, SimpleLoggingFacade) to avoid direct dependencies.
  2. If we end up using Enterprise Library for other facilities, then use it for Logging, too.
  3. If we end up using something with a dependency on Log4Net, use Log4Net.
  4. If none of the above, use NLog. Which I'd prefer.

基于这些发现(观点!)

That's based on these findings (opinions!):

  • 所有3个框架都有能力并且可以完成一些复杂的工作.我们需要一个优质的解决方案,但坦率地说,不需要超高性能或60种类型的事件接收器.
  • 所有3个都有非常相似的基本概念.
  • 每个都有自己的很酷的技巧,例如真正的高级路由,动态日志文件名,文件截断等.
  • 所有3个文件都以自己的方式很好地记录在案.
  • 对于像我这样的完整新手,他们最初有点尴尬.这里的基础知识没有太大的差异.我克服了它.
  • 几周后重新审视时,显然是最容易恢复的NLog.我只需要很少的刷牙就可以了.使用Log4Net,我不得不重新回顾一些在线示例才能开始.有了EntLib,我放弃了,并从头开始重新制作了这些教程-我完全迷失了.
  • 我不知道如何让EntLib执行某些操作,例如登录数据库.这可能很容易,但是超出了我的时间限制.
  • Log4Net和NLog的代码占用量很小. EntLib垃圾邮件,但无论如何我都会在其上使用外墙.
  • 我不小心配置了EntLib,它在运行时告诉我. Log4Net没有.我没有使用NLog意外配置错误.
  • EntLib带有一个漂亮的app.config编辑器,您100%需要它. NLog具有配置文件架构,因此您会得到"intellisense". Log4Net随附nada.
  • All 3 frameworks are capable and can do some sophisticated things. We want a quality solution, but frankly don't need ultra high performance or 60 types of event sinks.
  • All 3 have very similar basic concepts.
  • Each has its own cool tricks, like really advanced routing, or dynamic log filenames, file truncating, etc.
  • All 3 are pretty well documented in their own way.
  • For a complete newb like me, they were all a little awkward initially. No drastic differences here for the basics. I got over it.
  • When revisiting things a few weeks later, NLog was clearly the easiest to resume. I needed very little brush up on it. With Log4Net, I had to revisit a few online examples to get going. With EntLib, I gave up and did the tutorials all over again from scratch - I was totally lost.
  • I couldn't figure out how to get EntLib to do some things like log to the database. It might be easy, but it was beyond my time limit.
  • Log4Net and NLog have a small in-code footprint. EntLib is spammy, but I'd use a facade over it anyway.
  • I accidentally mis-configured EntLib and it told me at run time. Log4Net didn't. I didn't have an accidental mis-config with NLog.
  • EntLib comes with a nice looking app.config editor, which you 100% need. NLog has a config file schema so you get "intellisense". Log4Net comes with nada.

因此,到目前为止,很明显我喜欢NLog.尽管有其他解决方案,但仍不足以使用它.

So obviously I like NLog so far. Not enough to use it in spite of having another solution available, though.

这篇关于log4net与Nlog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆