[在此处插入您最喜欢的日志记录库]相对于 System.Diagnostics.Trace 有什么优势?

发布于 2024-11-08 13:38:26 字数 286 浏览 8 评论 0原文

如果我忽略了它,我很抱歉,但我无法立即找到类似的问题。

.Net 带有一些内置的日志记录功能(本质上是 System.Diagnostics.Debug 和 System.Diagnostics.Trace)。

是否有充分的理由不在典型的 LOB 应用程序中使用这些内置设施进行日志记录,而是使用 log4net、NLog、EntLib 日志记录块或[在此处插入您最喜欢的日志记录库]?

编辑:请注意,我更感兴趣的是查明 System.Diagnostics 日志记录功能的缺点,而不是不同日志记录库的功能。

Apologies if I overlooked it but I couldn't immediately find a similar question on SO.

.Net comes with some built-in logging capabilities (essentially, System.Diagnostics.Debug and System.Diagnostics.Trace).

Is there a good reason not to use these built-in facilities for logging purposes in a typical LOB application, and instead use log4net, NLog, EntLib logging block or [insert your favourite logging library here]?

EDIT: note that I am more interested in pinpointing the shortcomings of System.Diagnostics w.r.t. logging capabilities, rather than the features of the different logging libraries.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

岁月静好 2024-11-15 13:38:26

我更喜欢使用 NLog 或 log4net,因为它为我提供:

  1. 记录目标。我可以为特定目的选择最好的,而无需更改任何日志记录代码
  2. 我可以在某些情况下记录我需要的信息,这要归功于日志级别
  3. 我可以按照我喜欢的方式格式化我的日志条目,也可以以不同的方式针对不同的目标
  4. 性能是很好,谢谢你的批处理,
  5. 我不是发明轮子,
  6. 我可以多次重复使用它

I prefer to use NLog or log4net because it gives me:

  1. Logging targets. I can chose the best for certain purpose without changing any bit of logging code
  2. I can log the informations that I need at certain situation thanks to Log Levels
  3. I can format my Log Entry the way I like, also in different ways for diferent Targets
  4. Performance is quite ok, thanks for batching
  5. Im not inventing the wheel
  6. I can reause this many times
俯瞰星空 2024-11-15 13:38:26

能够将日志发送到多个端点(系统日志、数据库、事件日志等)可能会很有用。

Being able to send your logs to multiple endpoints (syslog, database, event log, etc) can be useful.

醉生梦死 2024-11-15 13:38:26

我使用 log4net,它的优点是在配置文件中您可以选择所需的日志记录级别(严重、错误、警告、信息、调试),并且您可以免费获得电子邮件日志记录和滚动日志文件等内容。

I use log4net and it's advantages are that in configuration files you can choose what level of logging you require (Critical, Error, Warning, Information, Debug) and you get things like email logging and rolling log files for free.

那片花海 2024-11-15 13:38:26

对于.net,我喜欢使用 http://netcommon.sourceforge.net/ doc-latest/reference/html/logging.html。它基本上是上面的包装层,因此在下面,您可以轻松切换日志引擎。不过它很像 log4net。

还有:

http://commons.apache.org/logging/guide.html

For .net, I like using http://netcommon.sourceforge.net/doc-latest/reference/html/logging.html. It's basically a wrapper layer above, so underneath, you can switch logging engines easily. It's very log4net like though.

There is also:

http://commons.apache.org/logging/guide.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文