官方配置文档:
https://logging.apache.org/log4j/2.x/manual/filters.html
根节点<Configuration>
文章来源:https://www.toymoban.com/news/detail-405823.html
<!--设置log4j2自身内部的信息输出级别为info-->
<!--Log4j每隔10秒自动检测修改配置文件和重新配置本身,不需要重启服务-->
<Configuration status="info" monitorInterval="10">
</Configuration>
参数介绍: 文章来源地址https://www.toymoban.com/news/detail-405823.html
Attribute Name | Description |
---|---|
name |
The name of the configuration. |
monitorInterval |
Log4j has the ability to automatically detect changes to the configuration file and reconfigure itself。 即动态加载,单位是秒。可自定义配置,最小间隔为5秒 |
status |
记录log4j本身的日志级别 The level of internal Log4j events that should be logged to the console. Valid values for this attribute are “off”, “trace”, “debug”, “info”, “warn”, “error”, “fatal”, and “all”. 如果需要对log4j进行故障排除,可设置status=“trace” 设置系统属性Log4j2.debug也会将内部Log4j2日志记录打印到控制台 |
advertiser | (Optional) The Advertiser plugin name which will be used to advertise individual FileAppender or SocketAppender configurations. The only Advertiser plugin provided is 'multicastdns". |
dest | Either “err” for stderr, “out” for stdout, a file path, or a URL. |
packages | Use of the packages attribute is deprecated and will be removed in Log4j 3.0. Plugins should be processed with the Log4j annotation processor. A comma separated list of package names to search for plugins. Plugins are only loaded once per classloader so changing this value may not have any effect upon reconfiguration. |
schema | Identifies the location for the classloader to located the XML Schema to use to validate the configuration. Only valid when strict is set to true. If not set no schema validation will take place. |
shutdownHook | Specifies whether or not Log4j should automatically shutdown when the JVM shuts down. The shutdown hook is enabled by default but may be disabled by setting this attribute to “disable” |
shutdownTimeout | Specifies how many milliseconds appenders and background tasks will get to shutdown when the JVM shuts down. Default is zero which mean that each appender uses its default timeout, and don’t wait for background tasks. Not all appenders will honor this, it is a hint and not an absolute guarantee that the shutdown procedure will not take longer. Setting this too low increase the risk of losing outstanding log events not yet written to the final destination. See LoggerContext.stop(long, java.util.concurrent.TimeUnit). (Not used if shutdownHook is set to “disable”.) |
strict | Enables the use of the strict XML format. Not supported in JSON configurations. |
verbose | Enables diagnostic information while loading plugins. |
到了这里,关于Log4j2的Configuration详解的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!