Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ba0d26e5
authored
Nov 22, 2023
by
Ren Ping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:日志输出
1 parent
cdad1494
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
384 additions
and
94 deletions
docker-compose/docker-compose.yml
project-gateway/src/main/resources/logback-spring.xml
project-order/src/main/resources/logback-spring.xml
project-user/src/main/resources/application-dev.yaml
project-user/src/main/resources/logback-spring.xml
docker-compose/docker-compose.yml
View file @
ba0d26e
...
...
@@ -113,6 +113,8 @@ services:
env_file
:
-
.env
container_name
:
project-gateway
volumes
:
-
/home/dev_boxi/logs:/logs
ports
:
-
${GATEWAY_PORT}:${GATEWAY_PORT}
depends_on
:
...
...
@@ -129,6 +131,7 @@ services:
container_name
:
project-order
volumes
:
-
/usr/local/src:/usr/local/src
-
/home/dev_boxi/logs:/logs
ports
:
-
${ORDER_PORT}:${ORDER_PORT}
-
"
62001:62001"
...
...
@@ -147,6 +150,8 @@ services:
env_file
:
-
.env
container_name
:
project-user
volumes
:
-
/home/dev_boxi/logs:/logs
ports
:
-
${USER_PORT}:${USER_PORT}
-
"
62000:5005"
...
...
@@ -213,7 +218,7 @@ services:
-
.env
container_name
:
project-dispatch
volumes
:
-
/home/dev_boxi/
project-dispatch/
logs:/logs
-
/home/dev_boxi/logs:/logs
ports
:
-
${DISPATCH_PORT}:${DISPATCH_PORT}
depends_on
:
...
...
project-gateway/src/main/resources/logback-spring.xml
0 → 100644
View file @
ba0d26e
<?xml version="1.0" encoding="UTF-8"?>
<!--该日志将日志级别不同的log信息保存到不同的文件中 -->
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<springProperty
name=
"LOG_MAXFILESIZE"
scope=
"context"
source=
"logback.filesize"
defaultValue=
"100MB"
/>
<springProperty
name=
"LOG_FILEMAXDAY"
scope=
"context"
source=
"logback.filemaxday"
defaultValue=
"30"
/>
<springProperty
name=
"spring.application.name"
scope=
"context"
source=
"spring.application.name"
defaultValue=
"spring-boot-fusion"
/>
<!-- 日志在工程中的输出位置 -->
<property
name=
"LOG_FILE"
value=
"logs/${spring.application.name:-}"
/>
<!-- 控制台的日志输出样式 -->
<property
name=
"CONSOLE_LOG_PATTERN"
value=
"%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"
/>
<!--日志文件输出格式-->
<property
name=
"FILE_LOG_PATTERN"
value=
"%d{yyyy-MM-dd HH:mm:ss} %-5level ${spring.application.name:-} %thread %logger %msg%n"
/>
<!-- 控制台输出 -->
<appender
name=
"CONSOLE"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
DEBUG
</level>
</filter>
<!-- 日志输出编码 -->
<encoder>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
<charset>
UTF-8
</charset>
</encoder>
</appender>
<appender
name=
"FILE_DEBUG"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/debug/${spring.application.name:-}.debug.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.debug-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<level>
DEBUG
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<appender
name=
"FILE_INFO"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/info/${spring.application.name:-}.info.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.info-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<!-- 异常文件输出设置,将异常堆栈另外保存一份到单独的文件中,方便查找 -->
<appender
name=
"FILE_ERROR"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/error/${spring.application.name:-}.error.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/error/${spring.application.name:-}.error-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<level>
ERROR
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<!-- 异常文件输出设置,将异常堆栈另外保存一份到单独的文件中,方便查找 -->
<appender
name=
"FILE_WARN"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/warn/${spring.application.name:-}.warn.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/warn/${spring.application.name:-}.warn-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印警告日志 -->
<level>
WARN
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<!-- 异步输出 -->
<appender
name=
"ASYNC"
class=
"ch.qos.logback.classic.AsyncAppender"
>
<!-- 0-不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>
0
</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>
256
</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref
ref=
"FILE_INFO"
/>
</appender>
<!-- 日志输出级别 -->
<root
level=
"info"
>
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"FILE_INFO"
/>
<appender-ref
ref=
"FILE_ERROR"
/>
<appender-ref
ref=
"FILE_WARN"
/>
</root>
</configuration>
\ No newline at end of file
project-order/src/main/resources/logback-spring.xml
View file @
ba0d26e
...
...
@@ -4,9 +4,8 @@
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<springProperty
name=
"LOG_MAXFILESIZE"
scope=
"context"
source=
"logback.filesize"
defaultValue=
"100MB"
/>
<springProperty
name=
"LOG_FILEMAXDAY"
scope=
"contex
m
t"
source=
"logback.filemaxday"
defaultValue=
"30"
/>
<springProperty
name=
"LOG_FILEMAXDAY"
scope=
"context"
source=
"logback.filemaxday"
defaultValue=
"30"
/>
<springProperty
name=
"spring.application.name"
scope=
"context"
source=
"spring.application.name"
defaultValue=
"spring-boot-fusion"
/>
<!-- 日志在工程中的输出位置 -->
...
...
@@ -19,9 +18,9 @@
<property
name=
"FILE_LOG_PATTERN"
value=
"%d{yyyy-MM-dd HH:mm:ss} %-5level ${spring.application.name:-} %thread %logger %msg%n"
/>
<!-- 控制台输出 -->
<appender
name=
"
console
"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<appender
name=
"
CONSOLE
"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
INFO
</level>
<level>
DEBUG
</level>
</filter>
<!-- 日志输出编码 -->
<encoder>
...
...
@@ -30,23 +29,44 @@
</encoder>
</appender>
<!-- 按照每天生成常规日志文件 -->
<appender
name=
"FileAppender"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_FILE}/info/${spring.application.name:-}.info.log
</file>
<appender
name=
"FILE_DEBUG"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/debug/${spring.application.name:-}.debug.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.debug-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
${FILE_LOG_PATTERN}
</pattern>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<!-- 基于时间的分包策略 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${LOG_FILE}/info/${spring.application.name:-}.info.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<!--保留时间,单位:天-->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<level>
DEBUG
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<appender
name=
"FILE_INFO"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/info/${spring.application.name:-}.info.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.info-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
...
...
@@ -74,30 +94,28 @@
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印警告日志 -->
<level>
WARN
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<appender
name=
"FILE_DEBUG"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_FILE}/debug/${spring.application.name:-}.debug.log
</file>
<!-- 异常文件输出设置,将异常堆栈另外保存一份到单独的文件中,方便查找 -->
<appender
name=
"FILE_WARN"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/warn/${spring.application.name:-}.warn.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/warn/${spring.application.name:-}.warn-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
${FILE_LOG_PATTERN}
</pattern>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<!-- 基于时间的分包策略 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.debug.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<!--保留时间,单位:天-->
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
DEBUG
</level>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印警告日志 -->
<level>
WARN
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
...
...
@@ -108,15 +126,17 @@
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>
256
</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref
ref=
"F
ileAppender
"
/>
<appender-ref
ref=
"F
ILE_INFO
"
/>
</appender>
<logger
name=
"org.springframework.jdbc.core.JdbcTemplate"
level=
"debug"
/>
<!-- 日志输出级别 -->
<root
level=
"
debug
"
>
<appender-ref
ref=
"
console
"
/>
<appender-ref
ref=
"F
ileAppender
"
/>
<root
level=
"
info
"
>
<appender-ref
ref=
"
CONSOLE
"
/>
<appender-ref
ref=
"F
ILE_INFO
"
/>
<appender-ref
ref=
"FILE_ERROR"
/>
<
!--<appender-ref ref="FILE_DEBUG"/>--
>
<
appender-ref
ref=
"FILE_WARN"
/
>
</root>
</configuration>
\ No newline at end of file
project-user/src/main/resources/application-dev.yaml
0 → 100644
View file @
ba0d26e
server
:
port
:
8000
spring
:
application
:
name
:
project-user
cloud
:
nacos
:
discovery
:
server-addr
:
nacos-server:8848
group
:
project
config
:
server-addr
:
nacos-server:8848
group
:
project
file-extension
:
yaml
config
:
import
:
-
optional:nacos:redis-config.yaml?group=project&refreshEnabled=true
main
:
allow-bean-definition-overriding
:
true
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
#url: jdbc:mysql://10.10.0.116:32306/saas_aftersale_test?serverTimezone=Asia/Shanghai
url
:
jdbc:mysql://localhost:32306/saas_aftersale_test?serverTimezone=Asia/Shanghai
username
:
boxi
password
:
boxi_dev_0725
type
:
com.alibaba.druid.pool.DruidDataSource
redis
:
database
:
0
host
:
redis
port
:
6379
password
:
123456
jedis
:
pool
:
max-active
:
32
min-idle
:
0
max-idle
:
8
max-wait
:
-1
kafka
:
bootstrap-servers
:
http://kafka:9092
consumer
:
group-id
:
mpGroup
#seata:
# application-id: ${spring.application.name}
# tx-service-group: ${spring.application.name}-group
# service:
# vgroup-mapping:
# project-user-group: default
# grouplist:
# default: seata-server:8091
project-user/src/main/resources/logback-spring.xml
View file @
ba0d26e
<?xml version="1.0" encoding="UTF-8"?>
<!--该日志将日志级别不同的log信息保存到不同的文件中 -->
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<springProperty
scope=
"context"
name=
"springAppName"
source=
"spring.application.name"
/>
<!-- Example for logging into the build folder of your project -->
<property
name=
"LOG_FILE"
value=
"logs/${springAppName}"
/>
<
!-- You can override this to have a custom pattern --
>
<
property
name=
"CONSOLE_LOG_PATTERN"
value=
"%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}
"
/>
<
springProperty
name=
"LOG_MAXFILESIZE"
scope=
"context"
source=
"logback.filesize"
defaultValue=
"100MB"
/
>
<
springProperty
name=
"LOG_FILEMAXDAY"
scope=
"context"
source=
"logback.filemaxday"
defaultValue=
"30"
/>
<springProperty
name=
"spring.application.name"
scope=
"context"
source=
"spring.application.name"
defaultValue=
"spring-boot-fusion
"
/>
<!-- Appender to log to console -->
<appender
name=
"console"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<!-- 日志在工程中的输出位置 -->
<property
name=
"LOG_FILE"
value=
"logs/${spring.application.name:-}"
/>
<!-- 控制台的日志输出样式 -->
<property
name=
"CONSOLE_LOG_PATTERN"
value=
"%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"
/>
<!--日志文件输出格式-->
<property
name=
"FILE_LOG_PATTERN"
value=
"%d{yyyy-MM-dd HH:mm:ss} %-5level ${spring.application.name:-} %thread %logger %msg%n"
/>
<!-- 控制台输出 -->
<appender
name=
"CONSOLE"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<!-- Minimum logging level to be presented in the console logs-->
<level>
DEBUG
</level>
</filter>
<!-- 日志输出编码 -->
<encoder>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
<charset>
utf
8
</charset>
<charset>
UTF-
8
</charset>
</encoder>
</appender>
<!-- Appender to log to file -->
<appender
name=
"flatfile"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_FILE}
</file>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${LOG_FILE}.%d{yyyy-MM-dd}.gz
</fileNamePattern>
<maxHistory>
7
</maxHistory>
<appender
name=
"FILE_DEBUG"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/debug/${spring.application.name:-}.debug.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.debug-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
<charset>
utf8
</charset>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<level>
DEBUG
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<appender
name=
"FILE_INFO"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/info/${spring.application.name:-}.info.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.info-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<!-- 异常文件输出设置,将异常堆栈另外保存一份到单独的文件中,方便查找 -->
<appender
name=
"FILE_ERROR"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/error/${spring.application.name:-}.error.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/error/${spring.application.name:-}.error-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<level>
ERROR
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<!-- Appender to log to file in a JSON format
<appender name="logstash" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_FILE}.json</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_FILE}.json.%d{yyyy-MM-dd}.gz</fileNamePattern>
<maxHistory>7</maxHistory>
<!-- 异常文件输出设置,将异常堆栈另外保存一份到单独的文件中,方便查找 -->
<appender
name=
"FILE_WARN"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/warn/${spring.application.name:-}.warn.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/warn/${spring.application.name:-}.warn-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<timestamp>
<timeZone>UTC</timeZone>
</timestamp>
<pattern>
<pattern>
{
"timestamp": "@timestamp",
"userId": "%X{userId:-}",
"severity": "%level",
"service": "${springAppName:-}",
"trace": "%X{traceId:-}",
"span": "%X{spanId:-}",
"pid": "${PID:-}",
"thread": "%thread",
"class": "%logger{40}",
"rest": "%message"
}
</pattern>
</pattern>
</providers>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
</appender> -->
<root
level=
"INFO"
>
<appender-ref
ref=
"console"
/>
<!-- uncomment this to have also JSON logs -->
<!--<appender-ref ref="logstash"/>-->
<!--<appender-ref ref="flatfile"/>-->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印警告日志 -->
<level>
WARN
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<!-- 异步输出 -->
<appender
name=
"ASYNC"
class=
"ch.qos.logback.classic.AsyncAppender"
>
<!-- 0-不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>
0
</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>
256
</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref
ref=
"FILE_INFO"
/>
</appender>
<logger
name=
"org.springframework.jdbc.core.JdbcTemplate"
level=
"debug"
/>
<!-- 日志输出级别 -->
<root
level=
"info"
>
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"FILE_INFO"
/>
<appender-ref
ref=
"FILE_ERROR"
/>
<appender-ref
ref=
"FILE_WARN"
/>
</root>
</configuration>
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment