I am trying to decide on what logging module to try out for my next project. I'd love the dev community's input on:
A) What logging lib you use
B) Whether you structure your logs (and how)
C) Where you store your logs or any other logging infra you have
I have been using Winston, but I would like something that supports structured logging out of the box. The general ecosystem on NPM seems to be pretty split, and some options seem to be popular but un-maintained.
Oldest comments (38)
I also do this. But Iām curious about other answers in the thread.
I'am using log4js in my project. But most of time I still using console.log() for debugging
I like using this, too. Log levels are super helpful
What will be the API you want for the logger ?
Since I'm just starting learning node I came to this post with some hesitation since I really didn't know if
console.log()was an acceptable answer. Thanks for the clarification. hahahaWe are using loglevel github.com/pimterry/loglevel to log errors and to debug code. Currently not storing the logs. All the "debug" logs are disabled in production builds.
my use cases :
1- in case of using Docker
A) Winston to log and store in txt file
B) structure based on the Service name, and Environment (stg or production)
C) Store in txt file, use filebeat to harvest and push to Logstash to index and store in Elastic search. then visualise it Kibana (ELK stack)
2- in case of using AWS Lambda
A) simple "console.log()"
B) not really
C) just use AWS CloudWatch
take a look at this:
github.com/pinojs/pino
hope it helps!
I use log4js or bunyan.
console.logandnode app.js > app.logwork fine most of the time.Sometimes, if I need to filter logs and stuff, I write them as json objects instead of plain files and create a very simple wrapper over
console.log, but I've never had the need to do anything very elaborated.like you, I've been using Winston (am still using it)
Winston, logging to console in development and console plus elastic stack in production.
I like the feature of sending JSON to elastic with the resulting possibility of organizing (filtering, sorting, searching, columns, ...) based on those JSON keys.