log4net 与 MS 日志记录应用程序块
我试图了解使用 log4netor 企业库日志记录应用程序块 (LAB) 来登录应用程序的优缺点。 我知道一件事 LAB 比 log4net 使用起来有点困难。
I am trying to understand pros and cons of using log4netor enterprise library logging application block (LAB) for logging in application. I know one thing LAB is little difficult to use then log4net.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用过 Log4Net,但不太喜欢它。 它绝对给人一种从另一种语言翻译而来的 API 的感觉。 然而,已经过去了几年了,所以从那时起它很可能得到了改进。
我更喜欢 LAB 的配置,但是当 LAB 无法工作时,几乎不可能找出原因。 这是最令人恼火的事情......它可以完美地工作,然后似乎突然停止,没有明显的原因。 我已经放弃了它(我使用的最后一个版本是 4.1),直到他们弄清楚如何使其易于调试。
我想说的是,如果您使用其他应用程序块,请坚持使用 LAB。 但在花了一周时间尝试调试日志失败后,请准备好放弃它。 如果您不使用其他块,请使用 Log4Net。
另外,如果您正在编写网络应用程序,请查看 ELMAH。 它更像是一个错误报告模块,但您可以通过手动引发事件将其用于基本日志记录。
I've used Log4Net, but I didn't like it so much. Its definitely got the feel of an API translated from another language. Its been a few years, however, so it could very well have been improved since then.
I liked the configuration for LAB better, however when the LAB doesn't work, it is nearly IMPOSSIBLE to figure out WHY. Its the most aggravating thing... It can work perfectly, then seem to stop suddenly for no apparent reason. I've given up on it (last version I used was 4.1) until they figure out how to make it easy to debug.
I'd say if you're using other application blocks, stick with LAB. But be prepared to drop it after spending a week trying to debug failures to log. If you're not using another block, use Log4Net.
Also, if you're coding a web application, check out ELMAH. It's more of an error reporting module, but you can use it for rudimentary logging by manually raising events.
我使用 Log4Net。 它已经与我使用的各种其他库(NHibernate)集成在一起,所以它很有意义。
如果您想了解更多信息,我有 Log4Net 简介。
http://elegantcode.com/2007/12/07/getting -started-with-log4net/
另外,就像 Will 所说的 LAB 一样,它可能很难配置(通过 xml 配置文件完成),但 Log4net 非常稳定。 此外,您还可以配置 Log4Net 来执行几乎任何您想要的操作(文本文件、滚动文本文件、记录到数据库、事件查看器等)
I use Log4Net. It is already integrated in with various other libraries I use (NHibernate) so it makes a lot of sense.
I have an Introduction to Log4Net if you want to read more.
http://elegantcode.com/2007/12/07/getting-started-with-log4net/
Also, like Will said about LAB, it can be difficult to configure (done via xml config files), but Log4net is very stable. Also, you can configure Log4Net to do almost anything you want (text files, rolling text files, log to database, Event Viewer, etc)