question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property "tailable: true" is not working as declared for winston File Transport

See original GitHub issue

Environment:

  • winston@3
  • node -v : v8.6.0 and v10.7.0
  • Operating System : Windows
  • Language ES6

Problem: I am using File winston transport in this way:

const fileTransport = new transports.File({
        filename: 'log.out',
        level: 'debug',
        maxsize: 100*1024, // 10 MB
        maxFiles: 3,
        json: false,
        tailable: true
    });

const logger = winston.createLogger({
    level: 'debug',
    format: combine(formatFile),
    transports: fileTransport,
    handleExceptions: true
});

File ‘log.out’ is created in necessary directory, but after the maxsize reached, logging is stopped, it means no files created. But in ‘tailable’ property description “If true, log files will be rolled based on maxsize and maxfiles, but in ascending order. The filename will always have the most recent log lines. The larger the appended number, the older the log file”

I think, problem is that code of creating new and renaming old log files is unreachable: from https://github.com/winstonjs/winston/blob/a32aa3c74859054f0351ac26b3079a5bc21f82b5/lib/winston/transports/file.js#L600

till https://github.com/winstonjs/winston/blob/a32aa3c74859054f0351ac26b3079a5bc21f82b5/lib/winston/transports/file.js#L609

due to internal error in asyncSeries() function: https://github.com/winstonjs/winston/blob/a32aa3c74859054f0351ac26b3079a5bc21f82b5/lib/winston/transports/file.js#L615 https://github.com/winstonjs/winston/blob/a32aa3c74859054f0351ac26b3079a5bc21f82b5/lib/winston/transports/file.js#L12

and this code is also unreachable: https://github.com/winstonjs/winston/blob/a32aa3c74859054f0351ac26b3079a5bc21f82b5/lib/winston/transports/file.js#L617 (only in case “maxFiles: 1”, then tasks array is empty)

Similiar Github issues: https://github.com/winstonjs/winston/issues/589 https://github.com/winstonjs/winston-daily-rotate-file/issues/23 (“still doesn’t work with winston@2.4.1”) https://github.com/winstonjs/winston/issues/1264

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
DABHcommented, Aug 28, 2018

Sweet. We will be publishing a 3.x update to npm very soon!

1reaction
jaxercommented, Aug 28, 2018

I can confirm that tailable is broken in 3.0.0 and fixed in master.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Logging to file with winston fails when in other module
The first time I visit localhost I get nothing (no logs). The second time I get "Error: Transport is in a failed state."...
Read more >
winston | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
winston - UNPKG
The CDN for winston. ... 4, - [#739](https://github.com/winstonjs/winston/issues/739), ... Allow `File` transport to be an `objectMode` writable stream.
Read more >
How to use the winston.format.printf function in winston - Snyk
TODO: Refactor options for logger (not for transport) if (!loggers.has(name)) { // add default Debug transport? const defaultTransports ...
Read more >
https://raw.githubusercontent.com/winstonjs/winsto...
v3.7.0 / 2022-03-30 Feature-level updates: - [#1989] Fix: resolve issues with metadata and ... (@pixtron) Log file without .gz for tailable (Fixes [#1525])....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found