Skip to content
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

Change Logback's maxHistory property default to 7 days #15875

Closed
anthofo opened this issue Feb 8, 2019 · 2 comments

Comments

Projects
None yet
5 participants
@anthofo
Copy link

commented Feb 8, 2019

Using Spring Boot 2.1.0 and logback.

It appears that the file-appender.xml configuration changed in Spring Boot 2 compared to Spring Boot 1.5 : 991468b#diff-cc7bd2aeeab66c424f816d9e42ea9e53

The 1.5 file:

<included>
	<appender name="FILE"
		class="ch.qos.logback.core.rolling.RollingFileAppender">
		<encoder>
			<pattern>${FILE_LOG_PATTERN}</pattern>
		</encoder>
		<file>${LOG_FILE}</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
			<fileNamePattern>${LOG_FILE}.%i</fileNamePattern>
		</rollingPolicy>
		<triggeringPolicy
			class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
			<MaxFileSize>10MB</MaxFileSize>
		</triggeringPolicy>
	</appender>
</included>

The 2.1 file:

<included>
	<appender name="FILE"
		class="ch.qos.logback.core.rolling.RollingFileAppender">
		<encoder>
			<pattern>${FILE_LOG_PATTERN}</pattern>
		</encoder>
		<file>${LOG_FILE}</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
			<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
			<maxFileSize>${LOG_FILE_MAX_SIZE:-10MB}</maxFileSize>
			<maxHistory>${LOG_FILE_MAX_HISTORY:-0}</maxHistory>
		</rollingPolicy>
	</appender>
</included>

The FixedWindowRollingPolicy has been changed for a SizeAndTimeBasedRollingPolicy.
The issue is that the previous FixedWindowRollingPolicy has a default rolling index of 7, keeping only 7 log files.

In Spring Boot 2.1, the SizeAndTimeBasedRollingPolicy is configured by default with a maxHistory of 0 (<maxHistory>${LOG_FILE_MAX_HISTORY:-0}</maxHistory>) , which means log files are kept indefinitly. Some of our servers crashed because of a full disk space, since old log files are not deleted anymore, this issue never happened with Spring Boot 1.5.

To prevent that, it would be great to set a default value (like 7 or 14) different than 0 for the maxHistory property. Users can still set the LOG_FILE_MAX_HISTORY property to set their own value if they wan, but it would prevent a lot of issues for users using the default config.

Thanks :)

@wilkinsona

This comment has been minimized.

Copy link
Member

commented Feb 26, 2019

Allowing an unbounded number of log files to be written doesn't seem like a particularly good default to me, so I agree we should take a look at changing it. We may also want to consider adding <totalSizeCap> as well. I don't think we should change things in a maintenance release, but I think it would be reasonable to make a change in 2.2.x. We just need to decide what that change should be.

@wilkinsona

This comment has been minimized.

Copy link
Member

commented Mar 6, 2019

We're going to default to a max history of 7. We'll leave <totalSizeCap> as-is for now.

@snicoll snicoll changed the title Consider setting the maxHistory property to a default value >0 in the logback conf file-appender.xml Change Logback's maxHistory property default to 7 days May 21, 2019

@snicoll snicoll self-assigned this May 21, 2019

@snicoll snicoll modified the milestones: 2.2.x, 2.2.0.M4 May 21, 2019

@snicoll snicoll closed this in ffbc545 May 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.