Log4j, meaning of Append = true / false

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.

Jon Skeet
people
quotationmark

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.)

people

See more on this question at Stackoverflow