New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Logback's FixedWindowRollingPolicy #1218

Merged
merged 2 commits into from Sep 3, 2015

Conversation

Projects
None yet
3 participants
@dennyac
Contributor

dennyac commented Aug 17, 2015

With Fixed Window Rolling Policy (archivedLogFilenamePattern: -%i), we have control on the size (maxFileSize) and the number of log files (archiveFileCount) that will reside on the host. We will not have to worry about disk usage warnings.

Recently Size and Time Based Archiving (archivedLogFilenamePattern: -%d-%i) with maxFileSize option has been added as part of commit: 343680b. In this archival policy we have control on the size of each log file (it will rotate the logs and increment the index after maxFileSize is reached), but the archiveFileCount only applies to the number of days worth of files that should be maintained. So on any specific day, files will keep getting rolled over indefinitely with a new index when the maxFileSize is reached. These log files will continue to accumulate as long as it is within the number of days mentioned in archiveFileCount. So we will lose control on the number and size of log files on the host, and disk usage may be a concern.

Proposed Approach:
Include FixedWindowRollingPolicy in FileAppenderFactory. Rolling policy to be used will be based on the archivedLogFilenamePattern -
Time Based Rolling Policy - /tmp/application-%d{yyyy-MM-dd}.log.gz
Size and Time Based Rolling Policy - /tmp/application-%d{yyyy-MM-dd}-%i.log.gz
Fixed Window Rolling Policy - /tmp/application-%i.log.gz

I hope you find this useful. I'm open to suggestions as well. Thanks.

@dennyac

This comment has been minimized.

Contributor

dennyac commented Aug 17, 2015

PS: The Travis CI build errors are unrelated to this change. I have tested it locally and it works as expected.

@jplock jplock added this to the 0.9.0 milestone Aug 17, 2015

@dennyac

This comment has been minimized.

Contributor

dennyac commented Aug 24, 2015

@jplock Please let me know if you have any suggestions or changes that have to be made. Thanks!

import ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP;
import ch.qos.logback.core.rolling.TimeBasedFileNamingAndTriggeringPolicy;
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
import ch.qos.logback.core.rolling.*;

This comment has been minimized.

@jplock

jplock Aug 25, 2015

Member

Can you revert this back to not using a wildcard? Then I think we're good to go. Thanks.

This comment has been minimized.

@dennyac

dennyac Aug 25, 2015

Contributor

Makes sense. I've made the changes you have suggested.

@nickbabcock

This comment has been minimized.

Contributor

nickbabcock commented Sep 3, 2015

I think this is a great feature because I just got bit twice in a short period of time by two different applications that spammed the log files and filled up the disk.

nickbabcock added a commit that referenced this pull request Sep 3, 2015

Merge pull request #1218 from dennyac/fixed-window-rolling-policy
Add support for Logback's FixedWindowRollingPolicy

@nickbabcock nickbabcock merged commit f9f1fec into dropwizard:master Sep 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment