log4j2设置日志文件读写权限(filePermissions)

spring-boot使用log4j2作为日志插件的时候需要设置日志文件的读写权限,可以File 上增加filePermissions,如:

<File name="File" fileName="logs/my.log" filePermissions="rw-r--rw-">
   <PatternLayout pattern="%m%n" />
</File>

需要注意的是,spring-boot version1.5.7.release的spring-boot-starter-log4j2中引用的log4j2的版本是2.7,而filePermissions只有在2.9以上的版本才有,所以需要在pom.xml中添加2.9的依赖

<dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.9.1</version>
        </dependency>
原文地址:https://www.cnblogs.com/tootwo2/p/7679443.html