`system.diagnostics.trace`和nlog/log4net之间的关系是什么?

发布于 2025-01-23 13:16:40 字数 413 浏览 1 评论 0原文

我正在学习ASP.NET Web API(框架,而不是核心)。通常,我将使用system.diagnostics.trace编写日志。但是一个兄弟建议使用nlog。

nlog/log4net system.diagnostics.trace的包装器吗?它会覆盖system.diarostics.trace的内置行为吗?什么是Microsoft扩展记录nlog.extensions.logging

如果我使用nlog,系统是否会从.NET Framework中登录也可以转到nlog目标?

我对上述概念感到困惑,您能帮我吗?

I am learning asp.net web API (framework, not core). generally, I will use system.diagnostics.trace to write logs. but a bro suggests to use Nlog.

is Nlog/log4net a wrapper of system.diagnostics.trace? will it override the built-in behavior of system.diagnostics.trace? And what are Microsoft Extension Logging and NLog.Extensions.Logging?

if I use Nlog, will the system log from .Net framework also turn to Nlog target?

I am confused with above concepts, can you help me?

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

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

发布评论

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

评论(1

左岸枫 2025-01-30 13:16:40

nlog.extensions.logging.logging

关于System.diagnostics.trace的好处是,它不会添加任何额外的依赖项。

NLOG / LOG4NET / SERILOG的好处是,它们使它们很容易将Loggging-Output重定向到许多不同的目标(File / Console / Console / Database / email /等),并为如何配置输出的布局 - 版本提供了许多选项(JSON / CSV / PLAIN-TEXT)。

example nlog.web.web for asp.net classic //nlog-project.org/config/?tab=layout-renderers&search = package:nlog.web“ rel =” nofollow noreferrer“> nlog extensions to nlog 以便于捕获Web-Request的上下文。前任。 $ {aspnet-request-urll}

NLog.Extensions.Logging and NLog.Web.AspNetCore is for Microsoft Extension Logging in ASP.NET Core.

The nice thing about system.diagnostics.trace is that it doesn't add any extra dependencies.

The nice thing about NLog/log4net/Serilog is that they make it easy to redirect logging-output to many different targets (file / console / database / email / etc.) and provides many options for how configure the layout-format of the output (json / csv / plain-text).

Forexample NLog.Web for ASP.NET Classic provides extensions to NLog for easy capture context of the web-request. Ex. ${aspnet-request-url}

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