winstonjs / winston-daily-rotate-file

A transport for winston which logs to a rotating file each day.
MIT License
889 stars 151 forks source link

How do I make my files append instead of overwriting when logging? #367

Open yongyan-foo opened 1 year ago

yongyan-foo commented 1 year ago

This is my configuration, I am able to create a log flow, but everytime my appliation resets, it deletes the existing logs. How can I make it append if the file already exists.

Here is my Configuration

const fileTransportOptions : DailyRotateFileTransportOptions = { 
    filename: `${process.env.LOG_DIR}/${process.env.APPLICATION_NAME}-%DATE%.log`,
    level: process.env.LOG_LEVEL??"info",
    datePattern: "YYYY-MM-DD",
    maxFiles: 365, 
    maxSize: "30mb", 
    zippedArchive: true,
    utc: true,
    options: { 
        flags: 'a'
    }
}
gustav87 commented 1 year ago

I'm also having this issue. I don't pass any options, and it should default to appending, but it still overwrites the previous log file on restart.

bbrodbeck-memtime commented 1 year ago

having same problem. It just removes the previous log file(s) instead of reusing it and appending new entries. This is quite annoying as we loose important logging information.