/
Example: Logging configuration for rolling log file

Example: Logging configuration for rolling log file

This article gives an example log configuration file and explains it roughly.

To activate this file, copy it to the directory containing all other configurations for tia Content Server Core and set the parameter logging.config with path and file name of this file.

 

Logging configuration for rolling log file

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: https://kgs-software.atlassian.net/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>

Related content

Example: Logging configuration to standard out
Example: Logging configuration to standard out
More like this
Configuration of logging framework in WAR file deployments.
Configuration of logging framework in WAR file deployments.
More like this
Example: Logging configuration for JSON logging
Example: Logging configuration for JSON logging
More like this
Configuration of logging framework in container deployment
Configuration of logging framework in container deployment
More like this
Logging for tia® server components
Logging for tia® server components
More like this
Example: Logging configuration for Email notification
Example: Logging configuration for Email notification
More like this