log4Net 中记录器和根级别之间的区别?

发布于 2024-10-09 23:11:32 字数 269 浏览 0 评论 0原文

我刚刚遇到 log4net 配置中的两个部分:

<logger name="File">
  <level value="All" />
</logger>
<root>
  <level value="INFO" />
</root>

我可以知道在记录器和根标记处指定级别有什么区别吗?它们之间有什么区别?

I just came across the two sections in log4net configiurations:

<logger name="File">
  <level value="All" />
</logger>
<root>
  <level value="INFO" />
</root>

May I know what is the difference of specifying levels at logger and root tags? What is the difference between them?

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

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

发布评论

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

评论(1

献世佛 2024-10-16 23:11:32

root 表示应用程序中的所有日志,而 logger 允许引用某种日志。使用它们,您只能更改某些日志的日志配置。查看您的示例并附上注释:

<!-- Set root logger level to INFO-->
<root>
    <level value="INFO" />
</root>

<!-- Print only messages of level WARN or above in the package "File" -->
<logger name="File">
    <level value="WARN" />
</logger>

在此示例中,所有日志均为 INFO,并且“文件”(或命名为文件)类型的日志为 WARN。

root means all logs in the application, and logger allows to refer to a certain kind of log. Using them you can change the log configuration only for cetain logs. Look your sample with comments:

<!-- Set root logger level to INFO-->
<root>
    <level value="INFO" />
</root>

<!-- Print only messages of level WARN or above in the package "File" -->
<logger name="File">
    <level value="WARN" />
</logger>

In this sample all logs are to INFO, and the the log of the type "File" (or named File) is WARN.

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