Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 2 Next »

This example demonstrates how to set up tia Content Server for file logging.

In line 2 to 5: Configure:

  • LOG_PATH - the folder to write the log into,

  • LOG_FILE - the log file name without file extension (as it is appended automaticalls in line 8), and

  • LOG_ARCHIVE - the folder to store older logs.

The paths depend on the deployment:

  • when deploying as container, the path are in container file system. As the logs should survive container life time, be sure to have a volume mapping to permanent network or host file system.

  • when deploying as WAR, the path is relative to the tomcat installation folder, e.g. C:\Program Files\Apache Software Foundation\Tomcat 10.1.

The FILE-ROLLING appender (line 7 to 23) defines

  • where the log file is written to using the parameters set before (line 8),

  • the rolling policy (line 10 to 18), which rules that:

    • the log file moves gz-compressed into the log archive folder everyday or whenever exceeding 10 MB

    • deleting log files from log archive after 60 days, or before when 20 GB of total allocation is exceeded.

  • In the encoder, the (enriched) format of the application log output is specified (line 20 to 22).

The default log file pattern is explained in this knowledge base article: /wiki/spaces/SUPPORT/pages/3661987841

The root tag is the main point to load these specifications. Here,

  • the default root log level is set, as well as

  • the appender bound for logging.

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

Example logging configuration file

<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>
  • No labels