Skip to content

Rotation and Retention of Log Files in Martini

Effective log management is crucial for maintaining the performance and reliability of any application, including Martini. This document outlines the essential processes of rotating and retaining log files within the Martini environment to ensure logs remain manageable and informative.

Log Rotation

Log rotation involves managing the size of log files by periodically archiving the current log file and creating a new one. This is crucial to prevent log files from becoming excessively large, which can consume too much disk space and potentially degrade system performance. Martini automatically handles log rotation based on predefined criteria such as file size or time intervals.

Log Retention

The retention policy for log files determines how long they should be kept before being deleted. This is important for ensuring that logs are available for a sufficient period for purposes such as historical analysis or debugging. Martini's log retention policy automatically deletes old log files based on their age or the total number of log files retained. This helps manage storage space effectively while keeping necessary log files accessible for as long as they are needed.

Rotation and Retention policy of Martini

The default time-based rotation policy utilizes the TimeBasedTriggeringPolicy, configured to rotate log files daily. This policy helps manage the accumulation of log data over time, ensuring that each day's logs are stored in separate files, which simplifies historical data retrieval and analysis. The configuration property for this policy is: appender.rolling.policies.time.type = TimeBasedTriggeringPolicy

In addition to time-based rotation, Martini also implements a size-based rotation policy. The SizeBasedTriggeringPolicy triggers a log rotation once the log file exceeds 10MB. This size limit helps prevent any single log file from becoming too large, which can hinder performance and complicate log management. The configuration property for this policy is: appender.rolling.policies.size.type = SizeBasedTriggeringPolicy

Note: 7 day retention period is only applicable for older log files

Modifying Default Policies

You can modify these default policies by navigating to the <martini-home>/conf/ directory and editing the log4j2.properties file. This flexibility allows administrators to tailor the log rotation and retention rules to better fit their specific system needs and logging requirements.

Together, these processes ensure that Martini's log management is both efficient and effective, providing timely and useful logging information while maintaining system performance and storage efficiency.