Skip to content

ivan-kleshnin/loggers-compared

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 

Repository files navigation

Logging solutions compared

Note: info is outdated. At this moment we use PinoJS and couldn't be happier. PinoJS is basically a better (cleaned and tuned) version of Bunyan logger used by NodeJS team.

The abscence of feature is not automatically BAD just and the presence is not automatically GOOD.

Features

Debug Log4Js Winston
Levels 1 5 6
Custom Levels - + +
Level Filter - + +
Custom Loggers + + +
Logger Filter + + +
Formats - + +
Custom Formats - + +
Transports console console, file, SMTP console, file, SMTP
Custom Transports - + +
File Rotation - + +
JSON support no no yes
Specifics profiling
logger wildcards
... profiling
querying(!)

Support

https://npmcompare.com/compare/debug,log4js,winston

Notes

  • Morgan – purpose? Trivial to implement on top of selected logger.

  • JSON logging – arguable.

Initially I felt like Log4JS has better defaults so decided to stick with it. Then I've found a significant drawback: Log4JS wants you to attach transports (called appenders there) to categories rather than loggers themselves. So you cannot define levels per transports per loggers.

I may be wrong, but I belive this (basic) case is not possible to configure with Log4JS:

WINSTON
  mainLogger
    transports
      console
        DEBUG
      file  
        INFO
      SMTP
        ERROR

Winston also understands exceptions so

try {
  throw Error("bad")
} catch (err) {
  logger.error(err)
}

logs valid JSON (note \n) (plain text is also configurable).

{"message":"bad","stack":"Error: bad\n    at Object.<anonymous> (/.../test/winston.js:14:8)\n    at Module._compile (module.js:573:32)\n    at Object.Module._extensions..js (module.js:582:10)\n    at Module.load (module.js:490:32)\n    at tryModuleLoad (module.js:449:12)\n    at Function.Module._load (module.js:441:3)\n    at Module.runMain (module.js:607:10)\n    at run (bootstrap_node.js:382:7)\n    at startup (bootstrap_node.js:137:9)\n    at bootstrap_node.js:497:3","level":"error","timestamp":"2016-11-07T09:28:41.799Z"}

Usage experience: Winston is hands down better than Log4JS in almost all aspects.

About

JS logging solutions compared

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published