Configure Log File Sizes and Rollovers

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

  1. Inlog4j2.xml , find the ADRRAFAppender element that you want to configure rollover attributes for.
  2. Modify the ADRolloverStrategy element and set values for these attributes:
    Attribute Description Type
    max The maximum number of log files. When the maximum number of files is reached, the oldest log file after the initial log file is deleted. String
    compressionLevel The degree of file compression, with 0 being uncompressed and 9 being the most compressed. String
    format The file format that the log is saved in. Options: zip , gz String
    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>
  3. Modify the SizeBasedTriggeringPolicy element and set values for these attributes:
    Attribute Description Type
    size The maximum log file size, in MB, before a log is rolled over. By default, the size is 20MB before the rollover, because the logs are compressed. String