I have several modules - let\'s say server.js, module1.js,...,moduleN.js.
I would like define the log file in my server.js:
winston.add(winston.trans
What I do ( which may not be the best way ) is use a 'global' module where I export all the stuff that I use through my applications. For instance:
//Define your winston instance
winston.add(winston.transports.File, { filename: 'mylogfile.log' });
exports.logger = winston;
exports.otherGlobals = ....
Now just require this globally used module from your other modules
var Global = require(/path/to/global.js);
Because the file is cached after the first time it is loaded (which you can verify by including a log statement in your global; it will only log once), there's very little overhead in including it again. Putting it all into one file is also easier than requiring ALL your globally used modules on every page.