This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
Winston Logger #10
priyansh32
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have set up Winston logger in the project; we do not need to use
console.log()
as it is not suitable for production.Instead of just logging in to the console, we can store required logs in a separate file in production. There are different services to host log files remotely. Saving logs will help us identify errors easily.
How to use winston logger?
Import
logger
using URLsrc/services/logger
relative to your file location.Winston has 7 different logging levels
You can use it like,
logger.debug("GET api/events")
,logger.error(err)
.Use suitable level to log anything
development
environment, It will log all levels into the console in a nice coloured human-readable formproduction
environment, It will log only the first three levels (error, warning and combined) in the console and a file; it will also save errors in a separate file.Beta Was this translation helpful? Give feedback.
All reactions