Attempt to write logs with no transports.
See original GitHub issuePlease tell us about your environment:
winston
version?-
winston@2
-
winston@3
-
node -v
outputs:- _Operating System? Linux
- _Language? ES6/7
What is the problem?
Attempt to write logs with no transports on console.
[winston] Attempt to write logs with no transports {"message":"Hey man, I am here!","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"App running on 3000","level":"info"}
What do you expect to happen instead?
Expect to write on console and combined.log and error.log files.
Other information
logger.js
import winston from 'winston'
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
//
// - Write to all logs with level `info` and below to `combined.log`
// - Write all logs error (and below) to `error.log`.
//
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' }),
new winston.transports.Console({ format: winston.format.json() })
]
})
winston.info('Hey man, I am here!')
export default logger
Usage on index.js
require('./lib/logger.js')
winston.info(`App running on ${port}`)
Obeservation error and combined.log has permission 777 event through is not the ideal.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:21
Top Results From Across the Web
Attempt to write logs with no transports - using default logger ...
In winston 3 you need to create a logger object, then add transport s to it. Winston 3 has many examples, but to...
Read more >How To Log Like A Boss With Node.js | by Eren Yatkin
[winston] Attempt to write logs with no transports {"message":"Test Log","level":"info"}. Because we have not configured it.
Read more >Attempt to write logs with no transports – using default logger ...
Best Solution. In winston 3 you need to create a logger object, then add transport s to it.
Read more >A Complete Guide to Winston Logging in Node.js - Better Stack
Learn how to start logging with Winston in Node.js and go from basics to best ... Here are some custom transports that you...
Read more >Winston Attempt to write logs with no transports
A transport for winston which logs to a rotating file. Logs can be rotated based on a date, size limit, and old logs...
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
@lukaswilkeer, Assuming that createLogger doesn’t already add the logger/stream to winston, just merely construct the logger.
Based on your code snippet, adding
winston.add(logger)
after you create your logger should solve the problem.You could also add more streams, loggers and once you require winston in any part of the application, it should return the configured logger.
I created a repro script and winston works correctly. The problem where Uncaught errors inside the application. (Not reported or proper winston error). Don’t know the root cause. In this case, winston.add(logger) solved the problem of transports.
Closed issue.