We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
winston
winston@2
winston@3
node -v
Here is how to reproduce the problem.
const logger = winston.createLogger({ transports: [ new winston.transports.File({ filename: "src/logs/access.log", level: "info" }), new winston.transports.File({ filename: "src/logs/errors.log", level: "error" }) ], format: winston.format.combine( winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), winston.format.errors({ stack: true }), winston.format.splat(), winston.format.json() ) }); logger.add( new winston.transports.Console({ format: winston.format.combine(winston.format.colorize(), winston.format.simple()) }) ); logger.info({ level: "info", message: "Incoming Request" }); process.exit()
The outcome is, it logs to the console, but doesn't log to the files because it takes some time to log to files.
So the solution can be making the logger.log function async Or Can someone suggest a workaround?
It should log to all the three transports, console and 2 files.
The text was updated successfully, but these errors were encountered:
You should be able to wait for the "finish" event, and exit then. See this section in the README: (https://github.com/winstonjs/winston#awaiting-logs-to-be-written-in-winston)
However, this behavior seems to be broken atm, at least for File transports - they don't flush on end: #1504
Sorry, something went wrong.
tldr: replace process.exit(1) with process.exitCode = 1;
process.exit(1)
process.exitCode = 1;
After wasting a couple of hours I hope this will help someone else.
No branches or pull requests
Please tell us about your environment:
winston
version?winston@2
winston@3
node -v
outputs: v11.13.0What is the problem?
Here is how to reproduce the problem.
The outcome is, it logs to the console, but doesn't log to the files because it takes some time to log to files.
So the solution can be making the logger.log function async
Or
Can someone suggest a workaround?
What do you expect to happen instead?
It should log to all the three transports, console and 2 files.
The text was updated successfully, but these errors were encountered: