Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

The root log level can be set as well by application-wide parameter logging.level.root.

Example logging configuration file

Code Block
<configuration>
    <property name="LOG_PATH" value="./logs" />
    <!-- Log file name without extension: .log is added in appender -->
    <property name="LOG_FILE" value="tiaCSCore" /> 
    <property name="LOG_ARCHIVE" value="${LOG_PATH}/archive" />
    
    <appender name="FILE-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_PATH}/${LOG_FILE}.log</file>

        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${LOG_ARCHIVE}/${LOG_FILE}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
            <!-- each archived file, size max 10MB -->
            <maxFileSize>10MB</maxFileSize>
            <!-- total size of all archive files, if total size > 20GB, it will delete old archived file -->
            <totalSizeCap>20GB</totalSizeCap>
            <!-- 60 days to keep -->
            <maxHistory>60</maxHistory>
        </rollingPolicy>

        <encoder>
		<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%32.32X{traceId}/%16.16X{spanId}] [%.-1p] [%20.20thread] %70.70(%30.30logger{10}.%M \(%4L\) ): %m%n</pattern>
        </encoder>
    </appender>

    <root level="ERROR">
        <appender-ref ref="FILE-ROLLING"/>
    </root>
</configuration>