Child logger loses its transports when added to `winston.loggers`
See original GitHub issueSo I’m starting to use winston after transferring from python to JS. I am used to child loggers from logging
and so I tried to do the same with winston
.
Here is my config:
import winston from 'winston';
const base_logger = winston.create({
level: 'info',
format: winston.format.json(),
transports: [
new winston.transports.Console({}),
]
});
const child = base_logger.child({});
console.log(child.transports); // working perfectly, has the console transport
winston.loggers.add('child', child);
console.log(winston.loggers.get('child'). transports); // doesn't work, shows an empty array
I will debug the code to try to find the problem, but I am about 90% sure I am using winston wrong.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
A Complete Guide to Winston Logging in Node.js - Better Stack
Winston is the most popular logging library for Node.js. ... to use two File transports, one that logs all messages to a combined.log...
Read more >Add module name in winston log entries - node.js
I found a better way to do this. I added an additional layer over the winston logger, in this case a function, that...
Read more >How to use the winston.createLogger function in winston - Snyk
createLogger ({ level: 'info', format: winston.format.json(), transports: [ // - Write to all logs with level `info` and below to `combined.log` ...
Read more >Node Logging Basics - The Ultimate Guide To Logging - Loggly
Winston. “A multi-transport async logging library for Node.js.” ... Child loggers specialize the parent logger object, effectively adding more context to ...
Read more >Best practices to collect, customize and centralize Node.js logs
You also want to spend some time configuring relevant logging transports. If you need to add a file logger, for example, don't forget...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this is a bug of winston.Container.
You can simply confirm this issue by following code:
I just ran into this as well. I wanted to have a default logger, and then spin off child loggers that are named. It don’t see how this is possible with the current API.