darrylwest/simple-node-logger

RollingFileAppender logs twice

Closed this issue · 2 comments

  const Logger  = require('simple-node-logger')
  let manager = Logger.createLogManager()

  manager.addAppender(manager.createRollingFileAppender({
    errorEventName: 'error',
    logDirectory: 'logs',
    fileNamePattern: '<DATE>.log',
    dateFormat:'YYYYMMDD'
  }))

  let log = manager.createLogger()
  log.info('test')

It logs to screen:

11:43:10.897 INFO  test

and to file:

11:43:10.897 INFO  test
11:43:10.897 INFO  test

What i am doing wrong?

How can i disable screen logging?

You should not be doing manager.addAppender(manager.create[...]). You should instead be only doing manager.create[...]. In your code you created the appender (which also added it), then added it manually.

The examples should be updated to not do this, since it will log twice just like you encountered.

thanks for spotting this; fixed in version 0.93.30