Reputation: 1244
Does logback rename existing log files with a numerical suffix, then re-create the original empty log file
or truncate the original log file in place after creating a copy
?
I am trying to use AWS Cloudwatch Agent with a Java application that uses logback. We currently using the RollingFileAppender
with FixedWindowRollingPolicy
and SizedBasedTriggeringPolicy
.
Upvotes: 3
Views: 1194
Reputation: 47865
A RollingFileAppender
is a FileAppender
which can rollover log files; this appender can log to a file named myLog.log
and when a given condition is met change its target to another file. It has two required sub components:
RollingPolicy
which performs the rolloverTriggeringPolicy
which determines if and when a rollover occursThat's the background, now, onto your question ... you wrote that you are using a FixedWindowRollingPolicy
so when rollover occurs Logback will rename the currentLogFle
as currentLogFle1
and then create a new currentLogFle
and this then becomes the active output target. So the answer to this question ...
Does logback rename existing log files with a numerical suffix, then re-create the original empty log file or truncate the original log file in place after creating a copy?
... is:
Logback will rename existing log files with a numerical suffix, then re-create the original empty log file.
There's a useful table in the docs describing this behaviour.
Upvotes: 4