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 Martini Server Runtime 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 prevents log files from becoming excessively large, consuming too much disk space, and potentially degrading system performance. Martini implements two log rotation policies:

  1. Time-Based Rotation: This policy automatically rotates logs daily, organizing each day's data into separate files for easier historical analysis.

    1
    2
    3
    # Defines the time-based trigger for general application logs
    appender.rolling.policies.time.type=TimeBasedTriggeringPolicy
    appender.rolling.policies.time.interval=1
    
    1
    2
    3
    # Defines the time-based trigger for HTTP access logs
    appender.rolling2.policies.time.type=TimeBasedTriggeringPolicy
    appender.rolling2.policies.time.interval=1
    
  2. Size-Based Rotation: This policy triggers rotation when a log file reaches 10MB, preventing performance issues from oversized files.

    1
    2
    3
    # Defines the size limit trigger for general application logs
    appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
    appender.rolling.policies.size.size=10MB 
    
    1
    2
    3
    # Defines the size limit trigger for HTTP access logs
    appender.rolling2.policies.size.type=SizeBasedTriggeringPolicy
    appender.rolling2.policies.size.size=10MB
    

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.

  1. Log Retention:
1
2
3
4
5
# Configures deletion strategy for general application logs
appender.rolling.strategy.action.type=Delete

# Configures deletion strategy for HTTP access logs
appender.rolling2.strategy.action.type=Delete
  1. Retention Period:
1
2
3
4
5
# Sets 7-day retention period for general application logs
appender.rolling.strategy.action.condition.ifLastModified.age=7D

# Sets 7-day retention period for HTTP access logs
appender.rolling2.strategy.action.condition.ifLastModified.age=7D

Modifying Default Policies

You can modify these default policies by navigating to the <martini-home>/conf/overrides 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.