|
@@ -1,31 +1,55 @@
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
-<!DOCTYPE configuration>
|
|
|
-<configuration>
|
|
|
- <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
|
|
- <include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
|
|
- <!--应用名称-->
|
|
|
- <property name="APP_NAME" value="mall-admin"/>
|
|
|
- <!--日志文件保存路径-->
|
|
|
- <property name="LOG_FILE_PATH" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/logs}"/>
|
|
|
- <contextName>${APP_NAME}</contextName>
|
|
|
- <!--每天记录日志到文件appender-->
|
|
|
- <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
|
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
|
|
+ <contextName>febs</contextName>
|
|
|
+ <springProperty scope="context" name="springAppName" source="spring.application.name"/>
|
|
|
+ <property name="log.path" value="log/admin-server" />
|
|
|
+ <property name="log.maxHistory" value="15" />
|
|
|
+ <property name="log.colorPattern" value="%magenta(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %boldCyan([${springAppName:-},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]) %yellow(%thread) %green(%logger) %msg%n"/>
|
|
|
+ <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5level [${springAppName:-},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}] %thread %logger %msg%n"/>
|
|
|
+
|
|
|
+ <!--输出到控制台-->
|
|
|
+ <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
|
|
+ <encoder>
|
|
|
+ <pattern>${log.colorPattern}</pattern>
|
|
|
+ </encoder>
|
|
|
+ </appender>
|
|
|
+
|
|
|
+ <!--输出到文件-->
|
|
|
+ <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
|
- <fileNamePattern>${LOG_FILE_PATH}/${APP_NAME}-%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
|
- <maxHistory>30</maxHistory>
|
|
|
+ <fileNamePattern>${log.path}/info/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
|
+ <MaxHistory>${log.maxHistory}</MaxHistory>
|
|
|
</rollingPolicy>
|
|
|
<encoder>
|
|
|
- <pattern>${FILE_LOG_PATTERN}</pattern>
|
|
|
+ <pattern>${log.pattern}</pattern>
|
|
|
</encoder>
|
|
|
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
|
+ <level>INFO</level>
|
|
|
+ <onMatch>ACCEPT</onMatch>
|
|
|
+ <onMismatch>DENY</onMismatch>
|
|
|
+ </filter>
|
|
|
</appender>
|
|
|
- <!--输出到logstash的appender-->
|
|
|
- <appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
|
|
- <destination>localhost:4560</destination>
|
|
|
- <encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
|
|
|
+
|
|
|
+ <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
|
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
|
+ <fileNamePattern>${log.path}/error/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
|
+ </rollingPolicy>
|
|
|
+ <encoder>
|
|
|
+ <pattern>${log.pattern}</pattern>
|
|
|
+ </encoder>
|
|
|
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
|
+ <level>ERROR</level>
|
|
|
+ <onMatch>ACCEPT</onMatch>
|
|
|
+ <onMismatch>DENY</onMismatch>
|
|
|
+ </filter>
|
|
|
</appender>
|
|
|
- <root level="INFO">
|
|
|
- <appender-ref ref="CONSOLE"/>
|
|
|
- <appender-ref ref="FILE"/>
|
|
|
- <appender-ref ref="LOGSTASH"/>
|
|
|
+
|
|
|
+ <root level="debug">
|
|
|
+ <appender-ref ref="console" />
|
|
|
+ </root>
|
|
|
+
|
|
|
+ <root level="info">
|
|
|
+ <appender-ref ref="file_info" />
|
|
|
+ <appender-ref ref="file_error" />
|
|
|
</root>
|
|
|
</configuration>
|