简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM