如题:
效果是:在/opt/myApps/logs/app1/app1.log
/opt/myApps/logs/app2/app2.log
每个应用独立存储日志;
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty scope="context" name="APPLICATION_NAME" source="spring.application.name"/>
<springProperty scope="context" name="LOG_HOME" source="logging.path"
defaultValue="/opt/myApps/logs"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-12(%d{yyyy-MM-dd HH:mm:ss.SSS}) |-%-5level [%thread] %c [%L] -| %msg%n
</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/${APPLICATION_NAME}/${APPLICATION_NAME}.log/</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/${APPLICATION_NAME}/%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
</root>
</configuration>
标签:log,dd,yyyy,APPLICATION,self4j,按微,日志,NAME
From: https://www.cnblogs.com/crazytrip/p/16629885.html