In AutoPilot SU33 and later, AutoPilot uses log4j2. Logging configuration is defined in the log4j2.xml file, located under AUTOPILOT_HOME (for example, /opt/nastel/AutoPilotM6). AP logging is not based on how old a log file is, but instead on the file size and the number (count) of files. But log4j2 does include options to rotate logs based on date and also a deletion action, which deletes files that are older than a certain number of days. This is triggered when the log file rolls over. Using this technique, it is possible to save certain count of logs, for a certain number of days.
Before you increase the limit on the number of files that can be saved, it's important to make sure that you have enough disk space on the file system, .
Storing Domain/CEP logs for 7 days
To save Domain/CEP logs for 7 days, changes required to the existing <DefaultRolloverStrategy> tag, under <RollingFile name="file" are
- Find the property
filePatternand add.%d{yyyyMMdd}, before.%i.log4j.gz. It would look likefilePattern="${sys:autopilot.home}/logs/log4j/${sys:server.container.name}.%d{yyyyMMdd}.%i.log4j.gz" - Update <policies> to include
<TimeBasedTriggeringPolicy/>. So, the<Policies>tag will now look like<Policies>
<OnStartupTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="20 MB"/>
<TimeBasedTriggeringPolicy/>
</Policies> - As we've made changes to
filePatterntag, corresponding changes are also needed to the<Pattern>tag, under<PatternLayout>tag. After changes, it looks like<PatternLayout>
<Pattern>%d{ISO8601} %-5p [%t!%c{1}] - %m%n</Pattern>
</PatternLayout> - Include the delete action and increase the count of files that can be created. (In the example below, this count is set using the variable max=100.)
<DefaultRolloverStrategy max="100" fileIndex="min">
<Delete basePath="${sys:autopilot.home}/logs/log4j" maxDepth="2">
<IfFileName glob="${sys:server.container.name}*.log4j.gz"/>
<IfLastModified age="P7D" />
</Delete>
</DefaultRolloverStrategy>
Storing WGS logs for the last 7 days
To save WGS logs for 7 days, changes required to the existing <DefaultRolloverStrategy> tag, under <RollingFile name="file_WGSExpert" are
- Find the property
filePatternand add.%d{yyyyMMdd}, before.%i.log4j.gz. It would look likefilePattern="${sys:autopilot.home}/logs/log4j/${sys:server.container.name}_wgs.%d{yyyyMMdd}.%i.log4j.gz" - Update <policies> to include
<TimeBasedTriggeringPolicy/>. So, the<Policies>tag will now look like<Policies>
<OnStartupTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="20 MB"/>
<TimeBasedTriggeringPolicy/>
</Policies> - As we've made changes to
filePatterntag, corresponding changes are also needed to the<Pattern>tag, under<PatternLayout>tag. After changes, it looks like<PatternLayout>
<Pattern>%d{ISO8601} %-5p [%t!%c{1}] - %m%n</Pattern>
</PatternLayout> - Include the delete action and increase the count of files that can be created. (In the example below, this count is set using the variable max=1000.)
<DefaultRolloverStrategy max="1000" fileIndex="min">
<Delete basePath="${sys:autopilot.home}/logs/log4j" maxDepth="2">
<IfFileName glob="*_wgs.*.log4j.gz"/>
<IfLastModified age="P7D" />
</Delete>
</DefaultRolloverStrategy>