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
Show 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:
...
@@ -113,6 +113,8 @@ services:
env_file
:
env_file
:
-
.env
-
.env
container_name
:
project-gateway
container_name
:
project-gateway
volumes
:
-
/home/dev_boxi/logs:/logs
ports
:
ports
:
-
${GATEWAY_PORT}:${GATEWAY_PORT}
-
${GATEWAY_PORT}:${GATEWAY_PORT}
depends_on
:
depends_on
:
...
@@ -129,6 +131,7 @@ services:
...
@@ -129,6 +131,7 @@ services:
container_name
:
project-order
container_name
:
project-order
volumes
:
volumes
:
-
/usr/local/src:/usr/local/src
-
/usr/local/src:/usr/local/src
-
/home/dev_boxi/logs:/logs
ports
:
ports
:
-
${ORDER_PORT}:${ORDER_PORT}
-
${ORDER_PORT}:${ORDER_PORT}
-
"
62001:62001"
-
"
62001:62001"
...
@@ -147,6 +150,8 @@ services:
...
@@ -147,6 +150,8 @@ services:
env_file
:
env_file
:
-
.env
-
.env
container_name
:
project-user
container_name
:
project-user
volumes
:
-
/home/dev_boxi/logs:/logs
ports
:
ports
:
-
${USER_PORT}:${USER_PORT}
-
${USER_PORT}:${USER_PORT}
-
"
62000:5005"
-
"
62000:5005"
...
@@ -213,7 +218,7 @@ services:
...
@@ -213,7 +218,7 @@ services:
-
.env
-
.env
container_name
:
project-dispatch
container_name
:
project-dispatch
volumes
:
volumes
:
-
/home/dev_boxi/
project-dispatch/
logs:/logs
-
/home/dev_boxi/logs:/logs
ports
:
ports
:
-
${DISPATCH_PORT}:${DISPATCH_PORT}
-
${DISPATCH_PORT}:${DISPATCH_PORT}
depends_on
:
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 @@
...
@@ -4,9 +4,8 @@
<configuration>
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<springProperty
name=
"LOG_MAXFILESIZE"
scope=
"context"
source=
"logback.filesize"
defaultValue=
"100MB"
/>
<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"
/>
<springProperty
name=
"spring.application.name"
scope=
"context"
source=
"spring.application.name"
defaultValue=
"spring-boot-fusion"
/>
<!-- 日志在工程中的输出位置 -->
<!-- 日志在工程中的输出位置 -->
...
@@ -19,9 +18,9 @@
...
@@ -19,9 +18,9 @@
<property
name=
"FILE_LOG_PATTERN"
<property
name=
"FILE_LOG_PATTERN"
value=
"%d{yyyy-MM-dd HH:mm:ss} %-5level ${spring.application.name:-} %thread %logger %msg%n"
/>
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"
>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
INFO
</level>
<level>
DEBUG
</level>
</filter>
</filter>
<!-- 日志输出编码 -->
<!-- 日志输出编码 -->
<encoder>
<encoder>
...
@@ -30,23 +29,44 @@
...
@@ -30,23 +29,44 @@
</encoder>
</encoder>
</appender>
</appender>
<!-- 按照每天生成常规日志文件 -->
<appender
name=
"FILE_DEBUG"
<appender
name=
"FileAppender"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_FILE}/info/${spring.application.name:-}.info.log
</file>
<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"
>
<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>
<charset>
UTF-8
</charset>
</encoder>
</encoder>
<!-- 基于时间的分包策略 -->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<level>
DEBUG
</level>
<fileNamePattern>
${LOG_FILE}/info/${spring.application.name:-}.info.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<onMatch>
ACCEPT
</onMatch>
<!--保留时间,单位:天-->
<onMismatch>
DENY
</onMismatch>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
</filter>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
</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>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
</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>
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
<onMismatch>
DENY
</onMismatch>
...
@@ -74,30 +94,28 @@
...
@@ -74,30 +94,28 @@
<onMatch>
ACCEPT
</onMatch>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</filter>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印警告日志 -->
<level>
WARN
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
</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"
>
<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>
<charset>
UTF-8
</charset>
</encoder>
</encoder>
<!-- 基于时间的分包策略 -->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印警告日志 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<level>
WARN
</level>
<fileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.debug.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<onMatch>
ACCEPT
</onMatch>
<!--保留时间,单位:天-->
<onMismatch>
DENY
</onMismatch>
<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>
</filter>
</appender>
</appender>
...
@@ -108,15 +126,17 @@
...
@@ -108,15 +126,17 @@
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>
256
</queueSize>
<queueSize>
256
</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref
ref=
"F
ileAppender
"
/>
<appender-ref
ref=
"F
ILE_INFO
"
/>
</appender>
</appender>
<logger
name=
"org.springframework.jdbc.core.JdbcTemplate"
level=
"debug"
/>
<!-- 日志输出级别 -->
<!-- 日志输出级别 -->
<root
level=
"
debug
"
>
<root
level=
"
info
"
>
<appender-ref
ref=
"
console
"
/>
<appender-ref
ref=
"
CONSOLE
"
/>
<appender-ref
ref=
"F
ileAppender
"
/>
<appender-ref
ref=
"F
ILE_INFO
"
/>
<appender-ref
ref=
"FILE_ERROR"
/>
<appender-ref
ref=
"FILE_ERROR"
/>
<
!--<appender-ref ref="FILE_DEBUG"/>--
>
<
appender-ref
ref=
"FILE_WARN"
/
>
</root>
</root>
</configuration>
</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"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--该日志将日志级别不同的log信息保存到不同的文件中 -->
<configuration>
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<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 --
>
<
springProperty
name=
"LOG_MAXFILESIZE"
scope=
"context"
source=
"logback.filesize"
defaultValue=
"100MB"
/
>
<
property
name=
"CONSOLE_LOG_PATTERN"
<
springProperty
name=
"LOG_FILEMAXDAY"
scope=
"context"
source=
"logback.filemaxday"
defaultValue=
"30"
/>
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=
"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"
>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<!-- Minimum logging level to be presented in the console logs-->
<level>
DEBUG
</level>
<level>
DEBUG
</level>
</filter>
</filter>
<!-- 日志输出编码 -->
<encoder>
<encoder>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
<charset>
utf
8
</charset>
<charset>
UTF-
8
</charset>
</encoder>
</encoder>
</appender>
</appender>
<!-- Appender to log to file -->
<appender
name=
"FILE_DEBUG"
<appender
name=
"flatfile"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_FILE}
</file>
<File>
${LOG_FILE}/debug/${spring.application.name:-}.debug.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<rollingPolicy
<fileNamePattern>
${LOG_FILE}.%d{yyyy-MM-dd}.gz
</fileNamePattern>
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<maxHistory>
7
</maxHistory>
<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>
</rollingPolicy>
<encoder>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
utf8
</charset>
<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>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<level>
ERROR
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
</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>
<appender
name=
"FILE_WARN"
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<fileNamePattern>${LOG_FILE}.json.%d{yyyy-MM-dd}.gz</fileNamePattern>
<File>
${LOG_FILE}/warn/${spring.application.name:-}.warn.log
</File>
<maxHistory>7</maxHistory>
<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>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<providers>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<timestamp>
<charset>
UTF-8
</charset>
<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>
</encoder>
</appender> -->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印警告日志 -->
<root
level=
"INFO"
>
<level>
WARN
</level>
<appender-ref
ref=
"console"
/>
<onMatch>
ACCEPT
</onMatch>
<!-- uncomment this to have also JSON logs -->
<onMismatch>
DENY
</onMismatch>
<!--<appender-ref ref="logstash"/>-->
</filter>
<!--<appender-ref ref="flatfile"/>-->
</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>
</root>
</configuration>
</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