You may want to limit the length of your agent log files to make troubleshooting easier. To do this, you can specify a maximum size for your log files. When a log reaches that size, it is then rolled over: the log file gets zipped, and a new blank log file is generated to store the next batch of log data. By default, a log file has a maximum size of 20 MB and can be rolled over four times. See Troubleshooting Java Agent Issues.
You can configure log rollover attributes in the log4j2.xml
- In
log4j2.xml , find the ADRRAFAppender element that you want to configure rollover attributes for.
- Modify the
ADRolloverStrategy element and set values for these attributes:
In the following example, "5" is the total number of log files with backups per appender type per set that we keep. In essence, each agent restart will create {number of appenders} files as a set. Then each file can grow up to "5" files total consisting of the first file and 4 backup log files before it rolls over.
<ADRRAFAppender name="BusinessTransactionsLogger" fileName="BusinessTransactions.log">
<PatternLayout pattern="[%t] %d{DATE} %5p - %m%n" />
<SizeBasedTriggeringPolicy size="20 MB" />
<ADRolloverStrategy max="5", compressionLevel="8", format="zip" />
</ADRRAFAppender>
- Modify the
SizeBasedTriggeringPolicy element and set values for these attributes: