Skip to content

transports.File is not flushing on end. #1504

@racquetmaster

Description

@racquetmaster

Please tell us about your environment:

  • winston version?
    • winston@2
    • winston@3
  • node -v outputs: v10.10.0
  • Operating System? (Windows, macOS, or Linux)
  • Language? (all | TypeScript X.X | ES6/7 | ES5 | Dart)

What is the problem?

File transport is not flushing on exit. Even when flushing per https://github.com/winstonjs/winston#awaiting-logs-to-be-written-in-winston

Steps to reproduce:

'use strict';

let winston = require('winston');
// VERSION: "winston": "^3.1.0",

let file_transport = new winston.transports.File({
    filename: `${__dirname}/myfile.log.json`,
});
let logger = winston.createLogger({
    transports: [file_transport],
});


async function run() {
    for (let i = 0; i < 1000; i++) {
        logger.info('message');
    }

    logger.info('THE LAST MESSAGE');

    await new Promise(resolve => {
        file_transport.on('finish', resolve);
        logger.end();
    });

    process.exit(1);
}

run();

What do you expect to happen instead?

all messages (including THE LAST MESSAGE) should be written to the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    winston-fileIssues to move to `winston-file` when we create it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions