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
.NET logging framework
提问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 Eric Tuttleman
回答by James Curran
回答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.
尽管我也使用了这里提到的其他一些 - 值得研究。