# Error: Invalid transport, must be an object with a log method

**URL:** <https://forum.codewithmosh.com/t/error-invalid-transport-must-be-an-object-with-a-log-method/17030>\
**Category:** Node\
**Created:** [December 14, 2022, 3:02pm UTC](https://forum.codewithmosh.com/t/error-invalid-transport-must-be-an-object-with-a-log-method/17030 "2022-12-14T15:02:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AhmedElewa95](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@AhmedElewa95](https://forum.codewithmosh.com/u/AhmedElewa95)\
**Post date:** [December 14, 2022, 3:02pm UTC](https://forum.codewithmosh.com/t/error-invalid-transport-must-be-an-object-with-a-log-method/17030/1 "2022-12-14T15:02:19Z")

</div>

in Nodejs course, handling and logging errors chapter, lectures 6 & 7 Mosh has added a new logfile.log by this approach:  
“winston.add(winston.transports.File , {filename : ‘logfile.log’});”  
but this approach is no longer valid so instead, you have to use this:  
" winston.add(  
new winston.transports.File({filename:‘logfile.log’})); ".

you also have to modify the approach of adding new log to mongoDB by :  
“winston.add(  
new winston.transports.MongoDB({db:‘mongodb://127.0.0.1/vidly’}));”

---

<div class="post-metadata">

**Author:** ![Hamidshehzad](https://avatars.discourse-cdn.com/v4/letter/h/c0e974/32.png) [@Hamidshehzad](https://forum.codewithmosh.com/u/Hamidshehzad)\
**Post date:** [July 27, 2024, 2:50am UTC](https://forum.codewithmosh.com/t/error-invalid-transport-must-be-an-object-with-a-log-method/17030/2 "2024-07-27T02:50:37Z")

</div>

Thank you! I just started researching this error, and you’ve already provided the answer.
