Objective
The On-Premise Contrast Server generates several log files while in use. This article details some suggested methods for managing them.
Process
There are two locations on the filesystem where the Contrast Server generates logs:
Contrast Server Application Logs
The Contrast Server application generates logs in $CONTRAST_HOME/data/logs
.
The application uses Apache Log4j 2 to manage logging levels, locations, sizing etc. with behaviour determined by the contents of the log4j2.xml
configuration file which can be found in $CONTRAST_HOME/data/conf
.
The documentation here details the format of the log4j2.xml
file, but the content is mostly self explanatory.
There are two main sections: Appenders
and Loggers
. The Appenders
section contains a section for each of the log files (RollingFile
) where the filenames, max size and rollover strategy is specified. The Loggers
section allows the logging level to be set for each file.
As an example, this section:
<RollingFile name="DAILY" fileName="${contrast.logs.dir}/logs/contrast.log"
filePattern="${contrast.logs.dir}/logs/contrast.%d.%i.log.gz" immediateFlush="true">
<PatternLayout>
<Pattern>%d{ddMMyy HH.mm.ss,SSS} {%X{session.id}} {%X{user.name}} {%X{remote.addr}} %-5p (%F:%L) %m%n
</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="1 GB"/>
</Policies>
<DefaultRolloverStrategy max="15"/>
</RollingFile>
manages the contrast.log
file. When the file reaches 1GB it is compressed into a log.gz
file and when 15 such files have been created the oldest will be deleted.
Tomcat Logs
The embedded Tomcat server that runs the Contrast Server application generates logs in $CONTRAST_HOME/logs
.
There is no built-in mechanism for managing logs within the embedded Tomcat server so log file management requires a custom solution. The suggested mechanism for this on Linux is to use the logrotate utility which is available in most distributions. A crontab
job can be created to manage the logrotate
schedule.