Limiting the size of log files in Spectrum

 Product Affected: Spectrum Technology Platform
Product Feature: Configurations

There are two main log files in Spectrum:  wrapper.log and server.log.
Depending on the level of detail being logged, these files can consume significant amounts of disk space. It can be desirable to limit the size of these log files.

1. Wrapper Log:

The behavior of the wrapper.log file is controlled by the <Spectrum install>/server/bin/wrapper/wrapper.conf file. 
Edit these two properties to restrict the amount of hard disk space the wrapper.log file will consume:

The wrapper.logfile.maxsize property controls how large the wrapper.log file can grow before it is rolled (e.g. to wrapper.log.1). 
The default value of '0' disables log rolling and allows the file to grow unrestricted.  To change this, set the property to the maximum size of the file you want to allow.  For example

will cause the wrapper.log file to roll when it reaches 50 megabytes.

The wrapper.logfile.maxfiles property controls how many "rolled" files will be kept on the system before the oldest is recycled. 
When the wrapper.log file reaches the wrapper.logfile.maxsize limit, it will be renamed to wrapper.log.n, where n is a number from 1 through wrapper.log.maxfiles. 
The oldest log file will have the largest n value, i.e. wrapper.log.1 will contain more recent information than wrapper.log.10. 

The default value of '0' means that there is no limit to the number of rolled log files that will be kept on the hard disk.  Set this property to the number of rolled log files to keep on the system.  For example, this setting
would result in the files wrapper.log, wrapper.log.1, wrapper.log.2, and wrapper.log.3 being retained.

2. Server log

The behavior of the server.log file is controlled by the <Spectrum_install_location>/server/app/conf/log4j.xml file or the <Spectrum_install_location>/server/app/conf/logback.xml file, depending on the version of Spectrum that is installed.
Spectrum 9 SP3 and later use logback.xml, while Spectrum 8 SP3 and earlier use log4j.xml.
By default, Spectrum limits the size of the server.log file to 10 MB. 
When the server.log file reaches that size, it is rolled over to server.log.1. 
Only a single rolled file is maintained.  To change this, edit the appropriate XML file. 

In Spectrum 8 SP3 and earlier, the log4j.xml file has this collection of tags:
<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
    <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
    <param name="File" value="../app/repository/logs/server.log"/>
    <param name="Append" value="true"/>
    <param name="MaxFileSize" value="10MB"/>
    <param name="MaxBackupIndex" value="1"/>

    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p [%c{1}] %m%n"/>
    <filter class="com.pb.spectrum.platform.server.common.logging.LogFilter"/>

The MaxFileSize and MaxBackupIndex attributes determine the maximum file size of server.log and how many rolled files will be kept on the system.

In Spectrum 9 SP3 and later, the logback.xml file contains this collection of tags:
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <pattern>%d %-5p [%c{0}] %m%n</pattern>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
    <filter class="com.pb.spectrum.platform.server.common.logging.LogbackFilter"/>

Modify the maxFileSize and maxIndex values to change the size and copies of the server.log file.

These changes will take effect when Spectrum is restarted.
UPDATED:  August 22, 2019