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
Allow multiple File transports for a logger #149
Conversation
Why only file? |
Adding a special exception for file is just a workaround. Doing something like that kind of defeats the point of having different extensible transports. In order to allow multiple of the same transport (which does sound like it might be a decent idea), a lot more has to change. The logger management has to change, and aside from allowing multiple of each transport type, things like querying and streaming have to be changed as well, as they assume there is only one of a particular transport. |
@chjj, you're right, it's a workaround for file. It specifically addresses this issue: #101. I don't think it defeats the purpose of different extensible transports, though, it just allows you to have more instances of the same type of transport (file, in this case). You're right there's more that has to change - for example, this changeset breaks a couple of test cases that expect the transport to have the name 'file', whereas it is now called 'file' + filename. The rest seems to be working fine, at least for my usage, since transports are usually iterated over and not queried by name. I don't know if adding support for multiple transports of the same kind is on your list, and if it is, I would be happy to use it when it's implemented, but until then I'll just have to stick with the workaround. |
Transport instances should have |
@pdobrev This is actually a pretty easy fix. Just set |
Thanks, @indexzero, I'll have a look when I get more time on my hands and will try to implement this the right way, not just as a half-assed workaround. |
Did this pull request ever make its way into the repository? A stack-overflow post mentioned it was merged into this forked repo, which works, but the current flatiron/winston doesn't support this feature. |
I'm still getting this error also with winston 0.7.2 |
Too bad it isn't as easy as just
My use case would be that e.g. with |
would be great to see this finally arriving in the master :/ |
@greenify this has been in master for a long time. Please take the time to read the documentation before commenting on issues 😈 https://github.com/winstonjs/winston#multiple-transports-of-the-same-type |
Makes it possible to use several File transports for one logger: