log4j.appender.LOGFILE.Append = true
The doc says:
If the append parameter is true, the file will be appended to. Otherwise, the file designated by filename will be truncated before being opened.
Does it mean that if Append = true, new logs will be appended to the tail of the file? Then what does "truncated" indicate? Content will be deleted before the file being opened?
Thank you.
In the log4j2 architecture, an appender is basically responsible for sending log messages to a certain output destination. Here are some of the most useful types of appenders that the library provides: ConsoleAppender – logs messages to the System console. FileAppender – writes log messages to a file.
Log4j2 RollingFileAppender is an OutputStreamAppender that writes log messages to files, following a configured triggering policy about when a rollover (backup) should occur. It also has a configured rollover strategy about how to rollover the file.
The Log4j logging settings are stored in the file app_data /conf/server/log4j. properties, where app_data is the application data folder. You can edit this file directly on the server or open it by clicking Settings > Logging.
Yes, "the file designated by filename will be truncated" means that any data that previously existed in the file will be gone. This is a more general concept than just logging.
Suppose you have a file initially containing the data "AB":
If you open it to append the value "C", the file will end up containing "ABC".
If you open it to truncate and then write "C", the file will end up containing "C".
If you open it to overwrite without truncating, the file will end up containing "CB". (This is rarely a useful option.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With