I am trying to to create multiple loggers by doing
winston.loggers.add('category1', {})
I thought to create new loggers by "new winston.Logger" and then adding them like this:
myNewLogger = new winston.Logger({transport: [...]})
winston.loggers.add('category1', myNewLogger)
but the Logger is changing the transports to an object instead on an array which causes an exception in
container.js line 52: options.transports = existing ? existing.slice() : [];
because an object does not have a slice method
thanks
The winston.loggers.add
method expects options to be passed to a new Logger
instance, not a Logger
instance itself. e.g.: this will work
winston.loggers.add('category1', { transports: [/* Your transports etc */] })
Why does winston.loggers.add('category1', {level: "error"})
not work? It treats "level" as transport, but I will use the default transport of main logger.
@ChristophAtAdlos did you ever figure out why this was? Having the same issue.
Most helpful comment
Why does
winston.loggers.add('category1', {level: "error"})
not work? It treats "level" as transport, but I will use the default transport of main logger.