An open API service indexing awesome lists of open source software.

https://github.com/ivan-kleshnin/loggers-compared

JS logging solutions compared
https://github.com/ivan-kleshnin/loggers-compared

Last synced: 7 months ago
JSON representation

JS logging solutions compared

Awesome Lists containing this project

README

          

# Logging solutions compared

**Note: info is outdated. At this moment we use [PinoJS](https://github.com/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](https://github.com/expressjs/morgan) – purpose? Trivial to implement on top of selected logger.

* JSON logging – [arguable](https://news.ycombinator.com/item?id=3896833).

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

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

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

```json
{"message":"bad","stack":"Error: bad\n at Object. (/.../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.