Silent option not working with winston.loggers.add configuration
See original GitHub issuePlease tell us about your environment:
winston
version? 3.0.0-rc4node -v
outputs: 8.4.0- Operating System? MacOS
- Language? ES6/7
What is the problem?
silent: true - option not working as expected for multiple logger use. I have a ‘winston.js’ file with a logger configuration I use on multiple files. winston.js
winston.loggers.add('customLogger', {
console: {
level: 'info',
label: 'info,
},
transports: [
new winston.transports.Console({
silent: true
}),
],
});
I then import the logger app.js
const winston = require('winston');
const logger = winston.loggers.get('customLogger');
logger.info('message');
The logs are not suppressed.
If I use createLogger in the app.js with the same configuration it works as expected. Can we get the silent option to work for multiple loggers use? Thank you
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
node.js - Disable winston logging when running unit tests?
Winston transports have a silent property that you can set, which is probably a little nicer than removing the entire transport. I add...
Read more >How to use the winston.createLogger function in winston - Snyk
To help you get started, we've selected a few winston.createLogger examples, based on popular ways it is used in public projects.
Read more >Complete Winston Logger Guide With Hands-on Examples
With Winston, you can change your code in a single place and customize the format of your logs (e.g., logging in JSON format,...
Read more >winston - npm
Start using winston in your project by running `npm i winston`. ... The recommended way to use winston is to create your own...
Read more >A Guide Into Logging in Node.js using Winston - Bird Eats Bug
This can lead to performance issues when logging a large amount of data, as such calls can block the ... Setting up the...
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
FWIW, I had the same issue using
winston.loggers.add
and retrieving them later. The loggers existed, e.g., callingget
on the named logger returned the logger, but it had an emptytransports
array, despite having been created with atransports
array in theadd
call.’This is an Electron (via electron-forge) app, Babel 6.24, etc. if that matters.
FWIW I think this is still an issue:
"winston": "^3.3.3"
my setup file looks like this:
my application files try to import like this:
import { loggers } from 'winston' const logger = loggers.get('logger')
a log like this:
logger.debug("test")
results in this:
console.error [winston] Attempt to write logs with no transports ...