Amazon-Cloudwatch [SOLVED]: Does Logback RollingFileAppender rename or truncate existing file

Amazon-Cloudwatch [SOLVED]: Does Logback RollingFileAppender rename or truncate existing file

Home Forums Amazon Web Services Amazon Cloudwatch Amazon-Cloudwatch [SOLVED]: Does Logback RollingFileAppender rename or truncate existing file

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #197288

    Cloudy Point
    Keymaster

    QuestionQuestion

    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.

    #197289

    Cloudy Point
    Keymaster

    Accepted AnswerAnswer

    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:

    • A RollingPolicy which performs the rollover
    • A TriggeringPolicy which determines if and when a rollover occurs

    That’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.

    Source: https://stackoverflow.com/questions/46352764/does-logback-rollingfileappender-rename-or-truncate-existing-file
    Author: glitch
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.