Skip to content

Commit

Permalink
Merge pull request #1530 from nobodyiam/rolling-logs
Browse files Browse the repository at this point in the history
use spring boot's new feature to rotate log files
  • Loading branch information
nobodyiam authored Oct 4, 2018
2 parents 44aae09 + a7f4a02 commit b3fb3fa
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 43 deletions.
3 changes: 1 addition & 2 deletions apollo-adminservice/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ server:
port: 8090

logging:
path: /opt/logs/100003172
file: ${logging.path}/apollo-adminservice.log
file: /opt/logs/100003172/apollo-adminservice.log
12 changes: 0 additions & 12 deletions apollo-adminservice/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,10 @@
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE"
value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}apollo-adminservice.log}" />
<property name="LOG_PATH" value="${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
</root>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/apollo-adminservice.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
</configuration>
2 changes: 2 additions & 0 deletions apollo-common/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ server.max-http-header-size=10240

# Spring Boot 2.0
management.endpoints.web.base-path=/
logging.file.max-size=50MB
logging.file.max-history=30
5 changes: 2 additions & 3 deletions apollo-configservice/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ctrip:

server:
port: 8080

logging:
path: /opt/logs/100003171
file: ${logging.path}/apollo-configservice.log
file: /opt/logs/100003171/apollo-configservice.log
12 changes: 0 additions & 12 deletions apollo-configservice/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,10 @@
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE"
value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}apollo-configservice.log}" />
<property name="LOG_PATH" value="${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
</root>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/apollo-configservice.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
</configuration>
3 changes: 1 addition & 2 deletions apollo-portal/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ server:
port: 8080

logging:
path: /opt/logs/100003173
file: ${logging.path}/apollo-portal.log
file: /opt/logs/100003173/apollo-portal.log

management:
health:
Expand Down
12 changes: 0 additions & 12 deletions apollo-portal/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,10 @@
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE"
value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}apollo-portal.log}" />
<property name="LOG_PATH" value="${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
</root>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/apollo-portal.%d{yyyy-MM-dd}.%i.log}</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
</configuration>

0 comments on commit b3fb3fa

Please sign in to comment.