simple-node-logger icon indicating copy to clipboard operation
simple-node-logger copied to clipboard

README section on Appenders not correct or implementation wrong

Open Nilzor opened this issue 7 years ago • 1 comments

The section says:

You can create a single logger / log manager and add multiple appenders with different log levels. For example, you can add a console appender that has a log level of warn and a file appender to debug.

See examples/category-logger.js for an example.

I have run the category-logger.js -example, and the output is as follows:

node .\category-logger.js
a category logger with console and file appenders...
log file:  /tmp/file-test.log
stats:  CategoryOne Map {
  'all' => 0,
  'trace' => 1,
  'debug' => 2,
  'info' => 1,
  'warn' => 0,
  'error' => 2,
  'fatal' => 0 }
stats:  CategoryTwo Map {
  'all' => 0,
  'trace' => 1,
  'debug' => 0,
  'info' => 0,
  'warn' => 1,
  'error' => 0,
  'fatal' => 1 }
17:43:29.878 TRACE CategoryOne this is a simple trace log statement (should not show)
17:43:29.879 DEBUG CategoryOne this is a simple debug log statement (should not show)
17:43:29.879 INFO  CategoryOne this is a simple info log statement/entry
17:43:29.879 WARN  CategoryTwo this is a simple warn log statement/entry
17:43:29.879 ERROR CategoryOne this is a simple error log statement/entry
Error event caught:  {"ts":1518194609879,"pid":10128,"category":"CategoryOne","level":"error","msg":["this is a simple error log statement/entry"]}
17:43:29.879 ERROR CategoryOne
Error event caught:  {"ts":1518194609879,"pid":10128,"category":"CategoryOne","level":"error","msg":[]}
17:43:29.879 FATAL CategoryTwo this is a simple fatal log statement/entry
17:43:29.879 TRACE CategoryTwo this is a simple trace log statement (should show)
17:43:29.879 DEBUG CategoryOne this is a simple debug log statement (should show)

Two issues I have with this:

  • The "Should not show" stuff is showing
  • It's two different loggers configured: log1 and log2. The README indicates that there should be only one logger , but mulitple appenders with different level configuration. This is what I would like to achieve as well, but I don't know how.

Nilzor avatar Feb 09 '18 16:02 Nilzor

Similar desire here. I am using the rolling log but also want things logged to console. Hoped to use this example to figure out how to add a console appender into the mix, but no luck.

TroyWolf avatar Nov 07 '19 20:11 TroyWolf