内容简介:翻译自:https://stackoverflow.com/questions/24172777/in-log4net-xml-configuration-is-priority-the-same-thing-as-level
的例子所示:
<root> <priority value="ALL" /> <appender-ref ref="LogFileAppender" /> <appender-ref ref="ConsoleAppender"/> </root>
但是, http://logging.apache.org/log4net/release/manual/configuration.html 中的log4net配置示例始终使用level元素显示它:
<root> <level value="DEBUG" /> <appender-ref ref="A1" /> </root>
在这种类型的配置是
<priority>
同样的
<level>
?
有人能指出我在解释这个问题的文档中的某个地方吗?
log4net中的Logger类没有Priority属性.我可以找到的优先级的唯一实例是在SmtpAppender中.所以进入代码我去了!
在XmlHierarchyConfigurator的ParseChildrenOfLoggerElement方法中,您将找到以下代码:
if (xmlElement.LocalName == "level" || xmlElement.LocalName == "priority") { this.ParseLevel(xmlElement, log, isRoot); }
啊!这两个值都被解析为相同的属性(ParseLevel方法除了分配,记录和管理“继承”值(这是一个可能的级别)之外并没有那么多,所以你有它; “level”和“priority”对您的配置具有完全相同的效果.我想这是为了保持与先前版本的库的某种向后兼容性,事实上它是由 this article about log4j 支持的:
In early versions of log4j, these were called category and priority, but now they’re called logger and level, respectively.
实际上,如果我们搜索“category”,XmlHierarchyConfigurator中有一个Configure方法,它包含以下代码:
// ... XmlElement xmlElement = (XmlElement)xmlNode; if (xmlElement.LocalName == "logger") { this.ParseLogger(xmlElement); } else { if (xmlElement.LocalName == "category") { this.ParseLogger(xmlElement); } else { if (xmlElement.LocalName == "root") { this.ParseRoot(xmlElement); } // ...
就是这样:级别和优先级可以互换,记录器和类别也是如此.
有趣的花絮:最后一个属性获胜,并且对于您在记录器上可能拥有的属性数量没有限制,因此这是有效的并且将级别设置为DEBUG
<root> <priority value="ALL" /> <priority value="ERROR" /> <level value="DEBUG" /> </root>
翻译自:https://stackoverflow.com/questions/24172777/in-log4net-xml-configuration-is-priority-the-same-thing-as-level
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 如何确定需求的优先级?
- RabbitMQ之优先级消息队列
- [译]HTTP/2的优先级
- Thymeleaf 模板布局和属性优先级
- Spring Boot RabbitMQ - 优先级队列
- CSS 基础(盒模型、选择器、权重、优先级)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Machine Learning
Kevin Murphy / The MIT Press / 2012-9-18 / USD 90.00
Today's Web-enabled deluge of electronic data calls for automated methods of data analysis. Machine learning provides these, developing methods that can automatically detect patterns in data and then ......一起来看看 《Machine Learning》 这本书的介绍吧!