您会推荐哪种日志记录工具/方法?

发布于 2024-11-26 21:14:32 字数 316 浏览 1 评论 0原文

我今天将为我的应用程序添加日志记录(滚动文本文件 + Windows 事件源),以便以后的应用程序调试变得可能且更容易。

我之前使用过 Log4Net 和 Enterprise Library Logging Application Block,现在正在考虑使用什么工具。我已经看过[现有工具的比较][1]。

但理想情况下,我想使用本机 .NET 类,例如 System.Diagnostics 中的类,以便它可以在任何项目、任何具有最高性能的客户端上使用。有任何示例应用程序吗?

您使用过哪种日志记录工具/方法,您会推荐哪种日志记录工具/方法?

谢谢,

I'm going to add Logging (to rolling text file + windows event source) for my application today so that later application debugging can be made possible and easier.

I've previously used Log4Net and Enterprise Library Logging Application Block and now thinking what tool to use. I've seen [this comparison of existing tools][1].

but ideally, I'd like to use native .NET classes such as classes in System.Diagnostics so that it can be used on any project, any client with highest performance. any sample application?

Which logging tool/approach have you worked with and would you recommend?

Thanks,

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

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

发布评论

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

评论(2

遥远的绿洲 2024-12-03 21:14:32

我想推荐 log4Net

i would like to recommend log4Net

残月升风 2024-12-03 21:14:32

我将使用 log4net 与 FileAppender:

http://logging.apache.org/log4net /release/config-examples.html

您可以通过在每次日志调用之前进行检查来确保日志记录尽可能快,即如果您没有配置相应的级别,则如下所示停止进行调用:

if (Log.IsInfoEnabled) Log.Info("Message");

这是您所能达到的最快速度。

确保在类中将记录器定义为静态成员,即所有实例都有一次性实例化成本:

class X {
    readonly static ILog Log = LogManager.GetLogger(typeof(X));
}

企业库日志记录存在一些严重的性能问题,因此我会像避免瘟疫一样避免它。

I would use log4net with the FileAppender:

http://logging.apache.org/log4net/release/config-examples.html

You can make sure that the logging is as fast as possible by doing checks before each log call i.e. as follows to stop the calls being made if you do not have the respective level configured:

if (Log.IsInfoEnabled) Log.Info("Message");

This is as fast as you will get.

Make sure you define a logger inside your class as a static member i.e. then you have a one-time instantiation cost for all instances:

class X {
    readonly static ILog Log = LogManager.GetLogger(typeof(X));
}

Enterprise library logging has some serious performance problems so I'd avoid it like the plague.

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