Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Logger instance to winston.loggers #607

Closed
sinai-doron opened this issue Apr 16, 2015 · 3 comments
Closed

Add a Logger instance to winston.loggers #607

sinai-doron opened this issue Apr 16, 2015 · 3 comments
Labels
FAQ Frequently Asked Questions

Comments

@sinai-doron
Copy link

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

@indexzero
Copy link
Member

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 */] })

@indexzero indexzero added the FAQ Frequently Asked Questions label Apr 21, 2015
@ChristophAtAdlos
Copy link

ChristophAtAdlos commented Jun 21, 2017

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.

@dooleyb1
Copy link

dooleyb1 commented Mar 6, 2020

@ChristophAtAdlos did you ever figure out why this was? Having the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FAQ Frequently Asked Questions
Projects
None yet
Development

No branches or pull requests

4 participants