Andrunevchyn

Andrunevchyn


May 2018
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  

Categories


Logback rollover issue

Andriy AndrunevchynAndriy Andrunevchyn

If your rollover config doesn’t work due to unknown reason – read this answer. I didn’t find  why logback cannot rename log , no process locked log file. The easiest way to fix issue just  remove mentioned parameter File 

<appender name="RF" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<param name="File" value="myappname.log" />
        <encoder>
			<charset>UTF-8</charset>
			<param name="Pattern"
				value="%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-6level [%file:%line] - %msg - %logger%n" />
		</encoder>
		<rollingPolicy
			class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
			<fileNamePattern>myappname-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
			<!-- each file should be at most 300MB, keep 60 days worth of history, 
				but at most 20GB -->
			<maxFileSize>300MB</maxFileSize>
			<maxHistory>60</maxHistory>
			<totalSizeCap>20GB</totalSizeCap>
		</rollingPolicy>
	</appender>

Now my default log file has ugly name like myappname-2018-05-02.0.log instead myappname.log but I didn’t find more elegant way to fix it. The weirdest thing is logback writes that information somewhere but I couldn’t find it on my log files so it took me some time to debug logback sources.

 

P.S.

Also somehow it’s linked to rollover period – it work for hourly rollover and doesn’t work for daily rollover at least in my case

andriy@andrunevchyn.com

Comments 0
There are currently no comments.