DEV Community

Cover image for What JS Logging library / tool do you use?
Daniel Golant
Daniel Golant

Posted on

What JS Logging library / tool do you use?

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)

Collapse
 
ben profile image
Ben Halpern

I also do this. But I’m curious about other answers in the thread.

Collapse
 
dyllanwli profile image
dyllanwx

I'am using log4js in my project. But most of time I still using console.log() for debugging

Collapse
 
offendingcommit profile image
Jonathan Irvin

I like using this, too. Log levels are super helpful

Collapse
 
revskill10 profile image
Truong Hoang Dung

What will be the API you want for the logger ?

Collapse
 
leoat12 profile image
Leonardo Teteo

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. hahaha

Collapse
 
mandava profile image
BM

We 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.

Collapse
 
mattisaemi profile image
Matti Saemi

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

Collapse
 
janguianof profile image
Jaime Anguiano • Edited

take a look at this:

github.com/pinojs/pino

hope it helps!

Collapse
 
shicongbuct profile image
shicong

I use log4js or bunyan.

Collapse
 
avalander profile image
Avalander

console.log and node app.js > app.log work 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.

Collapse
 
tedhagos profile image
Ted Hagos

like you, I've been using Winston (am still using it)

Collapse
 
chrisme profile image
Chris

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.