This article explains how to configure both size-based and time-based log rollover for node(domain or cep) logs in meshIQ AutoPilot using the log4j2.xml configuration file.
By default, node logs roll over based on size, but you can also configure them to rotate automatically after a specific time interval (for example, daily or every 2 days).
File Location
The configuration file, log4j2.xml, is located under the $AUTOPILOT_HOME directory, which can vary depending on your installation.
For example:
/opt/nastel/AutoPilotM6/log4j2.xml /opt/meshiq/platform/log4j2.xml
or any other user-defined AutoPilot installation path.
Default Behavior
By default, node logs in meshIQ AutoPilot use a size-based rollover policy similar to:
<SizeBasedTriggeringPolicy size="20 MB"/> <DefaultRolloverStrategy max="5"/>
This configuration rolls over the log file once it exceeds 20 MB and retains up to 5 rolled (backup) files.
Adding Time-Based Rollover
To enable time-based rollover, add the TimeBasedTriggeringPolicy element to the log4j2 configuration file.
This allows logs to roll automatically after a specified number of days while still keeping size-based rollover.
Example configuration for daily rotation:
<RollingFile name="nodeLog"
fileName="logs/node.log"
filePattern="logs/archive/node-%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
<Policies>
<!-- Rollover daily -->
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<!-- Rollover also when file exceeds 10 MB -->
<SizeBasedTriggeringPolicy size="10 MB"/>
</Policies>
<!-- Keep last 7 rolled files -->
<DefaultRolloverStrategy max="7"/>
</RollingFile>
Explanation of Parameters
| Setting | Description |
|---|---|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/> |
Rolls logs daily. To roll every 2 days, set interval="2". |
<SizeBasedTriggeringPolicy size="10 MB"/> |
Rolls logs when the file reaches 10 MB (whichever occurs first). |
<DefaultRolloverStrategy max="7"/> |
Retains 7 backup files and deletes older ones automatically. |
filePattern with %d{yyyy-MM-dd}
|
Adds the date to the rolled file name (e.g., node-2025-10-25-1.log.gz). |
If you want logs to roll every two days, modify the interval value as shown below:
<TimeBasedTriggeringPolicy interval="2" modulate="true"/>
Notes
The configuration applies to any RollingFile appender in the
log4j2.xmlfile.Restart the node process(DOMAIN or CEP) after making changes for the new settings to take effect.
You can combine both time-based and size-based rollover to manage log growth efficiently.
The EVT logs (AutoPilot server logs) use a hardcoded size-based rollover and do not support time-based or configurable backup options.
Related Articles