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

Current log file unreadable #381

Open pdot86 opened 1 year ago

pdot86 commented 1 year ago

I am unable to make the current log file readable- it stays in write-only mode until it is rotated out.

Example:

const logger = winston.createLogger({
  level: 'debug',
  transports: [
    new DailyRotateFile({
      dirname: '/var/log/app',
      filename: 'application-%DATE%.log',
      createSymlink: true,
      symlinkName: 'application.log',
      zipperArchive: true,
      maxSize: '20m',
      datePattern: 'YYYYMMDD',
      format((info, opts) => info.private ? false : info)
      options: { mode: 664 }
    })
  ]
})

This results in the following:

-rwxr-xr-x.     root    12345    Sep   12     22:48     application-20230912.log
--w------T.     root    34         Sep   13     14:26      application-20230913.log
lrwxrwxrwx.    root    30         Sep   13     14:26      application.log -> application-20230913.log

The issue I have is that the current log file is set to a 1200 permission the agent that reads logs is unable to read the current log file, and even though the symlink has sufficient permissions the agent is unable to read application.log either. The end result is that we are not able to collect logs until the file rotates so we are always a day behind.