C# .NET 日志框架

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/185542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:04:04  来源:igfitidea点击:

.NET logging framework

c#logging

提问by el_eduardo

In java world you have log4j and a a pretty decent logging framework, is there anything like that for C#/.NET?

在 Java 世界中,你有 log4j 和一个相当不错的日志框架,C#/.NET 有没有类似的东西?

回答by Ray

log4netwould be the obvious answer.

log4net将是显而易见的答案。

回答by Eric Tuttleman

Yep. Log4Net.

是的。日志网络

I've been using it for a while, it has been a life saver!

我已经使用了一段时间了,它已成为救命稻草!

回答by James Curran

There's also nLog, which is rather similar, but a bit more lightweight with less configuration.

还有nLog,它非常相似,但更轻巧,配置更少。

回答by epotter

NLog is a good option.

NLog 是一个不错的选择。

回答by Chad Moran

http://www.nlog-project.org/- NLog

http://www.nlog-project.org/- NLog

It's a very flexible and configurable logging tool that's very light-weight. You can set it up to log to many different locations (Console, SQL, File... etc). Very easy to use.

这是一个非常灵活和可配置的日志工具,非常轻量级。您可以将其设置为登录到许多不同的位置(控制台、SQL、文件...等)。非常容易使用。

It's even used by Rob Connery in his Storefront MVC project... http://blog.wekeroad.com/mvc-storefront/

它甚至被 Rob Connery 在他的 Storefront MVC 项目中使用... http://blog.wekeroad.com/mvc-storefront/

回答by Brendan Kowitz

I'd still say Log4Net is a safer options. Many other open source projects also use it, if you ever include one that does, then you've just reduced a dependency.

我仍然会说 Log4Net 是一个更安全的选择。许多其他开源项目也使用它,如果你曾经包含一个这样做的,那么你只是减少了依赖。

回答by Justin R.

Is there anything that the Windows Event Log + Log Parsercan't do for you?

有什么 Windows 事件日志 +日志解析器不能为您做的吗?

回答by Kevin Dostalek

We've always used the MS P&P Enterprise Library Logging Application Block. It's not particulary cool or elegant, but it is pretty flexible and well designed. Main reason I think we use it is that we use a lot of the other components from the EL, and they of course all have dependencies on the logging module. More Info Here.

我们一直使用 MS P&P Enterprise Library Logging Application Block。它不是特别酷或优雅,但它非常灵活且设计精良。我认为我们使用它的主要原因是我们使用了来自 EL 的许多其他组件,当然它们都依赖于日志记录模块。 更多信息在这里。

回答by CSharpAtl

Look at TraceSources and TraceListeners. It is built into .NET and configured with the config file.

查看 TraceSources 和 TraceListeners。它内置于 .NET 中并使用配置文件进行配置。

回答by devmode

Try the Enterprise Library Logging Application Block

尝试企业库日志记录应用程序块

Even though I have used a few others mentioned here too - it is worth looking into.

尽管我也使用了这里提到的其他一些 - 值得研究。