- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
log4j.properties
文件中log4j.rootLogger
属性的意义是什么?如果我不使用此属性会怎样?
示例:
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
如果我将此属性设置为 ERROR
模式会发生什么。
最佳答案
Samudra Gupta 在他的书中解释说1:
The
Logger
object is the main object that an application developer uses to log any message. TheLogger
objects acting within a particular instance of an application follow a parent-child hierarchy.
如果你有以下配置:
log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
log4j.logger.com.me.proj2=INFO
这是记录器层次结构最终的样子:2
Samudra Gupta 继续解释:
At the top of the hierarchy exists a root logger. The root logger exists outside the scope of any custom logger hierarchy that we may come up with. It always exists as the root logger for all possible logger hierarchies, and it has no namespace. All the other application-specific
Logger
objects are child objects to the root logger. The parent-child relationship of loggers signifies the dependency of the loggers acting within the same application. A child logger can inherit properties from its parent logger recursively up the tree. Typically, a child logger will inherit the following properties from its parent logger(s):
Level
: If the child logger has no explicit tree level specified, it will use the level of its closest parent or the first proper level it finds recursively up the hierarchy.Appender
: If there is no appender attached to a logger, the child logger uses the appender of its closest parent logger or the first appender it finds recursively up the tree.ResourceBundle
:ResourceBundles
are key-value pattern properties files used for the localization of logging messages. A child logger inherits anyResourceBundle
associated with its parent logger.
注意事项
1 Samudra Gupta,Pro Apache Log4j,第二版(加利福尼亚州伯克利:Apress,2005 年),24-25,ISBN13:978-1-59059-499 -5
2 Dominic Mitchell,Java 登录,http://happygiraffe.net/blog/2008/09/03/logging-in-java/ , 2014 年 5 月 26 日检索。
关于java - log4j.properties 文件中 log4j.rootLogger 属性的意义是什么?如果我不使用此属性会怎样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23869207/
我有一个使用 log4j2 进行日志记录的 Maven 项目。我想覆盖 RootLogger 的模式。 这是我的 log4j2.properties 文件: status = debug name=
如何使用 rootlogger = debug, stdout, logfile 配置 log4j.properties 和 org.apache.httpclient = debug 哪个进入日志文
我想在记录到文件时禁用到控制台的输出。请参阅下面的配置文件: log4j.rootLogger=info,stdout log4j.appender.stdout=org.apache.log4j.C
我已经为我需要的所有日志文件定义了附加程序。因此,我认为 rootLogger 不需要附加程序,因为 rootLogger 中没有任何内容可登录。因此,我将 log4j.properties 中的行更
我有一个 log4J 设置,其中根记录器应该将 ERROR 级别及更高级别的消息记录到控制台,另一个记录器将所有内容记录到系统日志。 log4j.properties 是: # Root logger
为什么是Log4j rootLogger 在我的应用程序中没有根据级别过滤日志事件?在我的 log4j.properties 中,我有几个记录器: log4j.rootLogger=info,stdo
java如何在运行时动态开启或关闭log4j2中rootLogger的一个appender? 例如,我想禁用 Console Appender: ...
log4j.properties 文件中的 log4j.rootLogger 属性有何意义?如果我不使用此属性会发生什么? 示例: # Set root logger level to DEBUG a
log4j.properties文件中log4j.rootLogger属性的意义是什么?如果我不使用此属性会怎样? 示例: # Set root logger level to DEB
我正在尝试诊断我的 Web 应用程序中的生产内存泄漏。该应用程序是在 Tomcat 7 和 mySQL 上运行的 GWT 应用程序,在 Debian 上运行 OpenJDK 1.6.0_18。 我启动
我是一名优秀的程序员,十分优秀!