Log Rotation — File Size, Retention, and Compression
Log rotation prevents log files from consuming unlimited disk space by automatically archiving old log content when size or time limits are reached. MideyeServer uses Logback’s rolling appenders to manage log file rotation.
Default rotation policy:
- Max file size: 10 MB
- Policy type:
FixedWindowRollingPolicy(numbered archives) - Trigger:
SizeBasedTriggeringPolicy - Compression: Disabled (can be enabled)
- Applies to: Both
mideyeserver.logandmideyeserver.error
Current configuration
Section titled “Current configuration”Both log files use identical rotation policies by default.
Default policy behavior
Section titled “Default policy behavior”When mideyeserver.log reaches 10 MB:
- Current log renamed:
mideyeserver.log→mideyeserver.log.1 - Previous archives shifted:
mideyeserver.log.1→mideyeserver.log.2, etc. - New empty log created:
mideyeserver.log - Oldest archive (if beyond configured window) is deleted
Example file listing after multiple rotations:
mideyeserver.log (current log)mideyeserver.log.1 (most recent archive)mideyeserver.log.2mideyeserver.log.3mideyeserver.log.4mideyeserver.log.5 (oldest archive)Configuration location
Section titled “Configuration location”Edit the logback.xml file for your platform — see Overview for platform-specific paths.
Changing maximum file size
Section titled “Changing maximum file size”Increase file size before rotation
Section titled “Increase file size before rotation”To rotate at 50 MB instead of 10 MB:
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder> <charset>utf-8</charset> <Pattern>${FILE_LOG_PATTERN}</Pattern> </encoder> <file>${LOG_PATH}/${LOG_FILE}</file> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <fileNamePattern>${LOG_PATH}/${LOG_FILE}.%i</fileNamePattern> </rollingPolicy> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>50MB</MaxFileSize> <!-- Changed from 10MB --> </triggeringPolicy></appender>Supported size units:
KB— Kilobytes (1024 bytes)MB— Megabytes (1024 KB)GB— Gigabytes (1024 MB)
Decrease file size
Section titled “Decrease file size”For environments with limited disk space:
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>5MB</MaxFileSize></triggeringPolicy>Configuring retention (number of archives)
Section titled “Configuring retention (number of archives)”By default, FixedWindowRollingPolicy without explicit minIndex/maxIndex keeps archives indefinitely (until manually deleted).
Limit number of archived files
Section titled “Limit number of archived files”Keep only the 10 most recent archives:
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <fileNamePattern>${LOG_PATH}/${LOG_FILE}.%i</fileNamePattern> <minIndex>1</minIndex> <maxIndex>10</maxIndex></rollingPolicy>When rotation occurs and 10 archives already exist, the oldest (.10) is deleted before shifting.
Keep more archives
Section titled “Keep more archives”For long-term retention:
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <fileNamePattern>${LOG_PATH}/${LOG_FILE}.%i</fileNamePattern> <minIndex>1</minIndex> <maxIndex>100</maxIndex></rollingPolicy>Enabling compression
Section titled “Enabling compression”Compress rotated log files to save disk space.
Gzip compression
Section titled “Gzip compression”Add .gz extension to the file name pattern:
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <fileNamePattern>${LOG_PATH}/${LOG_FILE}.%i.gz</fileNamePattern> <minIndex>1</minIndex> <maxIndex>10</maxIndex></rollingPolicy>Rotated files are now compressed:
mideyeserver.logmideyeserver.log.1.gzmideyeserver.log.2.gzmideyeserver.log.3.gzCompression ratio: Typically 85–95% size reduction for text logs.
Zip compression
Section titled “Zip compression”Alternatively, use .zip extension:
<fileNamePattern>${LOG_PATH}/${LOG_FILE}.%i.zip</fileNamePattern>Time-based rotation
Section titled “Time-based rotation”For daily rotation regardless of file size, use TimeBasedRollingPolicy.
Daily rotation
Section titled “Daily rotation”Rotate daily at midnight:
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder> <charset>utf-8</charset> <Pattern>${FILE_LOG_PATTERN}</Pattern> </encoder> <file>${LOG_PATH}/${LOG_FILE}</file>
<!-- TimeBasedRollingPolicy replaces both rollingPolicy and triggeringPolicy --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- Daily rollover --> <fileNamePattern>${LOG_PATH}/${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- Keep 30 days of history --> <maxHistory>30</maxHistory>
<!-- Optional: total size cap --> <totalSizeCap>10GB</totalSizeCap> </rollingPolicy></appender>Result:
mideyeserver.log (current day)mideyeserver.log.2026-02-24.logmideyeserver.log.2026-02-23.logmideyeserver.log.2026-02-22.logWeekly rotation
Section titled “Weekly rotation”Rotate weekly on Sundays:
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}/${LOG_FILE}.%d{yyyy-ww}.log</fileNamePattern> <maxHistory>12</maxHistory> <!-- Keep 12 weeks --></rollingPolicy>Monthly rotation
Section titled “Monthly rotation”<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}/${LOG_FILE}.%d{yyyy-MM}.log</fileNamePattern> <maxHistory>12</maxHistory> <!-- Keep 12 months --></rollingPolicy>Daily rotation with compression
Section titled “Daily rotation with compression”<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}/${LOG_FILE}.%d{yyyy-MM-dd}.log.gz</fileNamePattern> <maxHistory>30</maxHistory></rollingPolicy>Size and time-based rotation
Section titled “Size and time-based rotation”Combine both strategies: rotate daily OR when file reaches size limit.
Example: Daily or 50 MB
Section titled “Example: Daily or 50 MB”<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder> <charset>utf-8</charset> <Pattern>${FILE_LOG_PATTERN}</Pattern> </encoder> <file>${LOG_PATH}/${LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <!-- Daily rollover --> <fileNamePattern>${LOG_PATH}/${LOG_FILE}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<!-- Each file, per day, max 50MB --> <maxFileSize>50MB</maxFileSize>
<!-- Keep 30 days of history --> <maxHistory>30</maxHistory>
<!-- Total size cap: 10GB --> <totalSizeCap>10GB</totalSizeCap> </rollingPolicy></appender>Result (high-volume day):
mideyeserver.logmideyeserver.log.2026-02-24.0.log.gz (first 50MB from Feb 24)mideyeserver.log.2026-02-24.1.log.gz (second 50MB from Feb 24)mideyeserver.log.2026-02-24.2.log.gz (third 50MB from Feb 24)mideyeserver.log.2026-02-23.0.log.gz (Feb 23)Separate policies for each log
Section titled “Separate policies for each log”Configure different rotation policies for main and error logs.
Example configuration
Section titled “Example configuration”<!-- Main log: daily rotation, 30 days --><appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder> <charset>utf-8</charset> <Pattern>${FILE_LOG_PATTERN}</Pattern> </encoder> <file>${LOG_PATH}/${LOG_FILE}</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}/${LOG_FILE}.%d{yyyy-MM-dd}.log.gz</fileNamePattern> <maxHistory>30</maxHistory> </rollingPolicy></appender>
<!-- Error log: 5MB rotation, keep 20 files --><appender name="FILE-ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>WARN</level> </filter> <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> <evaluator> <expression>return logger.startsWith("com.mideye");</expression> </evaluator> <OnMismatch>DENY</OnMismatch> <OnMatch>NEUTRAL</OnMatch> </filter> <encoder> <charset>utf-8</charset> <Pattern>${FILE_LOG_PATTERN}</Pattern> </encoder> <file>${LOG_PATH}/${ERROR_FILE}</file> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <fileNamePattern>${LOG_PATH}/${ERROR_FILE}.%i.gz</fileNamePattern> <minIndex>1</minIndex> <maxIndex>20</maxIndex> </rollingPolicy> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>5MB</MaxFileSize> </triggeringPolicy></appender>Monitoring disk space
Section titled “Monitoring disk space”# Check log directory sizedu -sh /opt/mideyeserver6/log/
# Detailed breakdowndu -h /opt/mideyeserver6/log/ | sort -h
# Count log filesls -1 /opt/mideyeserver6/log/ | wc -lDisk usage alerts:
# Nagios / Check_MK/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /opt/mideyeserver6/log/
# Zabbixvfs.fs.size[/opt/mideyeserver6/log/,used]vfs.fs.size[/opt/mideyeserver6/log/,pfree]Get-ChildItem "C:\Program Files (x86)\Mideye Server 6\log" -Recurse | Measure-Object -Property Length -Sum | Select-Object @{Name="Size(MB)";Expression={[math]::Round($_.Sum/1MB,2)}}Manual log file management
Section titled “Manual log file management”Manually rotate logs
Section titled “Manually rotate logs”Force rotation without waiting for size/time trigger:
- Stop MideyeServer (or accept brief log loss)
- Rename current log:
Terminal window cd /opt/mideyeserver6/log/mv mideyeserver.log mideyeserver.log.manual-$(date +%Y%m%d) - Restart MideyeServer or wait for auto-creation
Archive old logs
Section titled “Archive old logs”Move old logs to archive storage:
# Create archive directorymkdir -p /archive/mideyeserver/$(date +%Y)
# Move logs older than 90 daysfind /opt/mideyeserver6/log/ -name "mideyeserver.log.*" -mtime +90 \ -exec mv {} /archive/mideyeserver/$(date +%Y)/ \;Delete old logs
Section titled “Delete old logs”# Delete logs older than 30 daysfind /opt/mideyeserver6/log/ -name "mideyeserver.log.*" -mtime +30 -delete
# Delete compressed logs older than 90 daysfind /opt/mideyeserver6/log/ -name "*.gz" -mtime +90 -deleteTroubleshooting
Section titled “Troubleshooting”Rotation not occurring
Section titled “Rotation not occurring”Check Logback configuration syntax:
# Look for errors in console outputsudo journalctl -u mideyeserver6 | grep -i "logback\|rolling"Verify file permissions:
ls -l /opt/mideyeserver6/log/# MideyeServer user must have write accessCheck disk space:
df -h /opt/mideyeserver6/log/# If disk is full, rotation may failFiles not compressed
Section titled “Files not compressed”Verify .gz extension in fileNamePattern:
<fileNamePattern>${LOG_PATH}/${LOG_FILE}.%i.gz</fileNamePattern>Compression requires write permissions to the log directory.
Rotation happening too often
Section titled “Rotation happening too often”Increase MaxFileSize:
<MaxFileSize>50MB</MaxFileSize>Or switch to time-based rotation — use TimeBasedRollingPolicy for predictable daily/weekly rotation.
Old files not being deleted
Section titled “Old files not being deleted”Add maxHistory to TimeBasedRollingPolicy:
<maxHistory>30</maxHistory>Add minIndex/maxIndex to FixedWindowRollingPolicy:
<minIndex>1</minIndex><maxIndex>10</maxIndex>Cannot read .gz files
Section titled “Cannot read .gz files”# View compressed logzcat mideyeserver.log.1.gz
# Search compressed logzgrep "ERROR" mideyeserver.log.1.gz
# Decompress permanentlygunzip mideyeserver.log.1.gz # Creates mideyeserver.log.1Best practices
Section titled “Best practices”- Enable compression — Save 85–95% disk space with minimal CPU cost
- Set maxHistory — Prevent unlimited log accumulation
- Monitor disk usage — Alert before disk fills up
- Balance size and frequency — Larger files reduce rotation overhead
- Test configuration — Verify rotation works before production deployment
- Document retention policy — Align with compliance and troubleshooting needs
- Consider external archival — Move old logs to cheaper storage (S3, NAS)
Related documentation
Section titled “Related documentation”- Overview: Log file locations and default configuration
- Log Levels: Reduce log volume by adjusting verbosity
- Syslog / Log Aggregators: Forward logs to external systems (reduces local storage needs)