Log4j2的Configuration详解

这篇具有很好参考价值的文章主要介绍了Log4j2的Configuration详解。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

官方配置文档:
https://logging.apache.org/log4j/2.x/manual/filters.html

根节点<Configuration>

<!--设置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模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 日志框架梳理(Log4j,Reload4j,JUL,JCL,SLF4J,Logback,Log4j2)

    文中代码示例获取:关注【 Qin的学习营地 】,回复【 日志框架梳理 】 在了解日志框架时总会列出一系列框架:Log4j,Reload4j,JUL,JCL,SLF4J,Logback,Log4j2,这么多框架让人感到混乱,该怎么选取、该怎么用。接下来,让我们逐步理清这些框架及之间的关系。 首先来了解日志

    2024年02月05日
    浏览(51)
  • Log4j反序列化命令执行漏洞(CVE-2017-5645)&Apache Log4j2 lookup JNDI 注入漏洞(CVE-2021-44228)

    Apache Log4j是一个用于Java的日志记录库,其支持启动远程日志服务器。Apache Log4j 2.8.2之前的2.x版本中存在安全漏洞。攻击者可利用该漏洞执行任意代码 环境:vulhub 工具下载地址: ysoserial 利用工具生成payload: 1.创建文件 进入容器内部,查看文件创建成功 2.查看反弹的shell 有点

    2024年02月11日
    浏览(44)
  • 深入理解 SpringBoot 日志框架:从入门到高级应用——(五)Log4j2配置文件详解

    Log4j2 官方文档:https://logging.apache.org/log4j/2.x/manual/index.html Log4j2 是一个Java日志框架,用于记录应用程序在运行时的信息。它是 Log4j 的升级版本,提供了更快的处理速度,更快的日志记录和更丰富的日志记录功能,并支持异步日志记录,减少了对应用程序性能的影响。它可以

    2024年02月05日
    浏览(38)
  • Spring Boot 配置 log4j2

    本教程中,我们将学习如何在 Spring Boot 中整合使用 Log4j2 日志框架。 Spring Boot 中默认使用 Logback 作为日志框架,接下来我们将学习如何在 Spring Boot 中集成与配置 Log4j2。在配置之前,我们需要知道的是 Log4j2 是 Log4j 的升级版,它在 Log4j 的基础上做了诸多改进: 1.异步日志;

    2024年02月08日
    浏览(30)
  • Log4j2 配置日志记录发送到 kafka 中

    前言 log4j2 在 2.11.0 之后的版本,已经内置了 KafkaAppender 支持可以将打印的日志直接发送到 kafka 中,在这之前如果想要集中收集应用的日志,就需要自定义一个 Layout 来实现,相对来说还是比较麻烦的。 官网文档:Log4j – Log4j 2 Appenders 依赖 配置 注意这里有个 syncSend 控制着是

    2024年02月10日
    浏览(30)
  • Springboot整合与使用log4j2日志框架【详解版】

    Spring Boot默认使用LogBack,但是我们没有看到显示依赖的jar包,其实是因为所在的jar包spring-boot-starter-logging都是作为spring-boot-starter-web或者spring-boot-starter依赖的一部分。 如果这里要使用Log4j2,需要从spring-boot-starter-web中去掉spring-boot-starter-logging依赖,同时显示声明使用Log4j2的依

    2024年02月11日
    浏览(42)
  • java 项目配置slf4j - log4j2

    2024年02月13日
    浏览(37)
  • Java日志系统log4j2的使用配置和异步日志使用

    Apache Log4j2是Log4j的升级版,参考了logback一些优秀的设计,并且修复了logback的一些问题,而且性能上也有了重大提升,主要有: log4j2对Appender提供了一些异常处理机制 参考了logback的设计,提供自动刷新参数配置,可以自动重载配置而不用重启应用 log4j2利用缓冲区和重用对象

    2024年02月02日
    浏览(41)
  • [CVE-2021-44228]:log4j2漏洞学习与复现流程详解(vulhub环境)

    刚搭好vulhub,迫不及待的来复现一下2021-2022最潮最in的漏洞log4j2,因为算是热点了面试什么的的感觉都蛮容易被问到的,这里就来整理一下这个漏洞相关信息和漏洞复现的流程。 影响版本:log4j 2.x = 2.14.1 漏洞简介 首先肯定得简单了解一下log4j2到底是什么东西,log4j2是Apache的

    2024年02月08日
    浏览(35)
  • log4j2漏洞分析

    和前面的JNDI注入时用的代码差不多 如果要引入log4j2的jar包可以这么配置Maven的pom.xml 还要创建个配置文件 log4j2这个漏洞当时爆出来的时候堪称是核弹级别的,危害非常大,利用还非常简单,既然如此,那我们肯定要分析一下漏洞相关的原理来学习一下 这个漏洞是个JNDI注入漏

    2024年02月09日
    浏览(42)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包