Log4j2的RollingFileAppender详解

RollingFileAppender:实现日志文件自动更新

当满足条件(日志大小、指定时间等)重命名打包原日志文件进行归档,生成新日志文件用于日志写入。

参数 Type Description
name String The name of the Appender.
fileName String The name of the file to write to. If the file, or any of its parent directories, do not exist, they will be created.
filePattern String The pattern of the file name of the archived log file.
createOnDemand boolean 当该属性设置为true时,Log4j将根据需要(即首次有日志事件需要写入时)创建指定的日志文件,而不是在应用程序启动时立即创建。. Defaults to false.
xml 复制代码
    <appenders>
        <RollingFile name="SIZE_BASED_TRIGGERING"
                     fileName="${LOG_HOME}/${FILE_NAME}.log"
                     filePattern="${LOG_HOME}/${FILE_NAME}_%d{yyyy-MM-dd}_%i.log.gz" 
                     createOnDemand="true">
        </RollingFile>
    </appenders>
相关推荐
百***48071 小时前
【Golang】slice切片
开发语言·算法·golang
q***92511 小时前
Windows上安装Go并配置环境变量(图文步骤)
开发语言·windows·golang
仟濹2 小时前
【Java 基础】面向对象 - 继承
java·开发语言
6***83052 小时前
微服务搭建----springboot接入Nacos2.x
java
郝学胜-神的一滴2 小时前
Linux命名管道:创建与原理详解
linux·运维·服务器·开发语言·c++·程序人生·个人开发
2501_941623322 小时前
C++高性能网络服务器与epoll实战分享:大规模并发连接处理与事件驱动优化经验
开发语言·php
晚风(●•σ )2 小时前
C++语言程序设计——11 C语言风格输入/输出函数
c语言·开发语言·c++
likuolei3 小时前
XML 元素 vs. 属性
xml·java·开发语言
X***48963 小时前
C源代码生成器
c语言·开发语言
自不量力的A同学3 小时前
Spring Boot 4.0.0 正式发布
java·spring boot·后端