Skip to content

Commit

Permalink
always create log file
Browse files Browse the repository at this point in the history
  • Loading branch information
Lesrac committed Jun 26, 2024
1 parent d3d210f commit ce4e13c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 72 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- feature/*
- develop
release:
types: [created]

Expand Down
131 changes: 59 additions & 72 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,81 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">

<logger name="org.springframework" level="INFO" />
<logger name="org.springframework" level="INFO"/>

<property name="LOG_LEVEL_PATTERN" value="%highlight(%level)" />
<property name="LOG_EXCEPTION_CONVERSION_WORD" value="%rEx" />
<property name="LOG_LEVEL_PATTERN" value="%highlight(%level)"/>
<property name="LOG_EXCEPTION_CONVERSION_WORD" value="%rEx"/>

<springProfile name="!any">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%highlight(%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}) | %highlight(${LOG_LEVEL_PATTERN:-%5p}) | %highlight(%magenta(${PID:- })) | %highlight(%yellow(%X{traceId:-None})) | %highlight([%15.15t]) | %highlight(%cyan(%-40.40logger{39})) | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%ex}
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</springProfile>
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOGGING_FILE_NAME:-./cdr-client.log}</file>
<append>true</append>

<springProfile name="customer">
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOGGING_FILE_NAME:-./cdr-client.log}</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOGGING_FILE_NAME:-./cdr-client.log}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>${LOGGING_LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-100MB}</maxFileSize>
<maxHistory>${LOGGING_LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-2}</maxHistory>
</rollingPolicy>

<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOGGING_FILE_NAME:-./cdr-client.log}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>${LOGGING_LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-100MB}</maxFileSize>
<maxHistory>${LOGGING_LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-2}</maxHistory>
</rollingPolicy>

<encoder>
<pattern>%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC} | ${%level:-%5p} | ${PID:- } | %X{traceId:-None} | [%15.15t] | %-40.40logger{39} | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%ex}
</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<timestamp>
<fieldName>timestamp</fieldName>
<timeZone>UTC</timeZone>
</timestamp>
<loggerName>
<fieldName>logger</fieldName>
</loggerName>
<logLevel>
<fieldName>level</fieldName>
</logLevel>
<threadName>
<fieldName>thread</fieldName>
</threadName>
<nestedField>
<fieldName>mdc</fieldName>
<providers>
<mdc />
</providers>
</nestedField>
<stackTrace>
<fieldName>stackTrace</fieldName>
<!-- maxLength - limit the length of the stack trace -->
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<maxDepthPerThrowable>200</maxDepthPerThrowable>
<maxLength>14000</maxLength>
<rootCauseFirst>true</rootCauseFirst>
</throwableConverter>
</stackTrace>
<message />
<throwableClassName>
<fieldName>exceptionClass</fieldName>
</throwableClassName>
</providers>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="ROLLING" />
<appender-ref ref="STDOUT" />
</root>
</springProfile>
<encoder>
<pattern>%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC} | ${%level:-%5p} | ${PID:- } | %X{traceId:-None} | [%15.15t] | %-40.40logger{39} |
%m%n${LOG_EXCEPTION_CONVERSION_WORD:-%ex}
</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<timestamp>
<fieldName>timestamp</fieldName>
<timeZone>UTC</timeZone>
</timestamp>
<loggerName>
<fieldName>logger</fieldName>
</loggerName>
<logLevel>
<fieldName>level</fieldName>
</logLevel>
<threadName>
<fieldName>thread</fieldName>
</threadName>
<nestedField>
<fieldName>mdc</fieldName>
<providers>
<mdc/>
</providers>
</nestedField>
<stackTrace>
<fieldName>stackTrace</fieldName>
<!-- maxLength - limit the length of the stack trace -->
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<maxDepthPerThrowable>200</maxDepthPerThrowable>
<maxLength>14000</maxLength>
<rootCauseFirst>true</rootCauseFirst>
</throwableConverter>
</stackTrace>
<message/>
<throwableClassName>
<fieldName>exceptionClass</fieldName>
</throwableClassName>
</providers>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="ROLLING"/>
<appender-ref ref="STDOUT"/>
</root>

</configuration>

0 comments on commit ce4e13c

Please sign in to comment.