Skip to content

Commit

Permalink
Merge pull request #71 from gerry-f2c/pr@v3@perf_log_format
Browse files Browse the repository at this point in the history
perf: Optimize log format
  • Loading branch information
Aaron3S authored Dec 23, 2024
2 parents 2054095 + a4fb744 commit 692f93f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ COPY --from=stage-chen-build /opt/chen/backend/web/target/web-*.jar /opt/chen/ch
COPY --from=stage-chen-build /opt/chen/entrypoint.sh .
COPY --from=stage-chen-build /opt/chen/drivers /opt/chen/drivers
COPY --from=stage-chen-build /opt/chen/config/application.yml /opt/chen/config/application.yml
COPY --from=stage-chen-build /opt/chen/config/logback.xml /opt/chen/config/logback.xml

ARG VERSION
ENV VERSION=$VERSION
Expand Down
5 changes: 1 addition & 4 deletions config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ server:
enabled: true

logging:
level:
root: INFO
file:
name: data/logs/chen.log
config: config/logback.xml

spring:
messages:
Expand Down
27 changes: 27 additions & 0 deletions config/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss,Asia/Shanghai} [%-5level] [%thread] [%-30.30logger{30}] %msg%n"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss,Asia/Shanghai} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>data/logs/chen.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>data/logs/chen.log.%d{yyyy-MM-dd}.%i.gz</FileNamePattern>
<maxFileSize>10MB</maxFileSize>
<compressionMode>GZ</compressionMode>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss,Asia/Shanghai} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>

<logger name="org.springframework.*" level="INFO"/>
<logger name="org.jumpserver.chen.*" level="INFO"/>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</configuration>
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [ ! "$LOG_LEVEL" ]; then
LOG_LEVEL=ERROR
fi

sed -i "s@root: INFO@root: ${LOG_LEVEL}@g" /opt/chen/config/application.yml
sed -i "s@level=\"INFO\"@level=\"${LOG_LEVEL}\"@g" /opt/chen/config/logback.xml

echo
date
Expand Down

0 comments on commit 692f93f

Please sign in to comment.