Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zipping the archives is overriding the already zipped logs #99

Closed
gitmnikhil opened this issue Oct 20, 2017 · 4 comments
Closed

Zipping the archives is overriding the already zipped logs #99

gitmnikhil opened this issue Oct 20, 2017 · 4 comments

Comments

@gitmnikhil
Copy link

We have a scenario where we are rotating the logs every 10Mb. When the number of request are high the log file is generated almost every second.

We have set zippedArchive to true. On first file it successfully zip the file and create a new file. But as soon as another file is ready to be archived, It overwrites the previous one as they have the same name instead of creating a new archive.

Config

new winston.transports.DailyRotateFile({
      name: 'info-file',
      filename: 'logs/info.log',
      level: loggerConfig.level,
       datePattern: 'yyyy-MM-dd.',
       colorize: true,
       level: loggerConfig.level,
       prepend: true,
       // 10 MB max file size then rotate
       maxsize: 10485760
    })
@gitmnikhil
Copy link
Author

gitmnikhil commented Nov 2, 2017

@mattberther Can you please confirm, if this is a configuration issue or the module bug.

@nirmaldas84
Copy link

nirmaldas84 commented Nov 3, 2017

We observed that the application exits with exception when max size is reached and zipping is being performed.

Following exception was observed:

Error: EPERM: operation not permitted, stat 'F:\Project Code\logs\app-logger\2017-11-03.info.log

Stack strace

C:\Users\Nirmal.COMPRO\AppData\Roaming\npm\node_modules\pm2\lib\API\Extra.js:70
fmt.field('uid', process.geteuid());
^
TypeError: process.geteuid is not a function
at C:\Users\Nirmal.COMPRO\AppData\Roaming\npm\node_modules\pm2\lib\API\Extra.js:70:34
at C:\Users\Nirmal.COMPRO\AppData\Roaming\npm\node_modules\pm2\node_modules\pm2-axon-rpc\lib\client.js:45:10
at Parser. (C:\Users\Nirmal.COMPRO\AppData\Roaming\npm\node_modules\pm2\node_modules\pm2-axon\lib\sockets\req.js:67:8)
at emitOne (events.js:115:13)
at Parser.emit (events.js:210:7)
at Parser._write (C:\Users\Nirmal.COMPRO\AppData\Roaming\npm\node_modules\pm2\node_modules\amp\lib\stream.js:91:16)
at doWrite (_stream_writable.js:387:12)
at writeOrBuffer (_stream_writable.js:373:5)
at Parser.Writable.write (_stream_writable.js:290:11)
at Socket.ondata (_stream_readable.js:642:20)

Configuration used:

new winston.transports.DailyRotateFile({
        name: 'error-file',
        filename: path.resolve(loggerConfig.directory, "err.log"),
        handleExceptions: true,
        humanReadableUnhandledException: true,
        level: 'error',
        datePattern: 'yyyy-MM-dd.',
        prepend: true,
        maxsize: 307200,
        zippedArchive: true
    })

Debugging Info
_createStream is called based on comparison of maxsize with buffer size (this._size)
image

However, in comparison of maxsize is done with stat.size (which is smaller) and hence log file to be used next does not get incremented name
image

Finally, the exception
image

@mattberther
Copy link
Member

Some long-overdue refactoring of the transport has occurred. A PR is available at #107. Also, a pre-release version has been published to npm. Please npm install [email protected] and reopen this issue if the problem remains.

@drewwiens
Copy link

We had the same issue as @nirmaldas84 with EPERM when zipping. Upgrading from 1.4.6 to latest (3.2.1 at time of writing) solved it for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants