How can I log any errors from ExpressJS apps into a file?
I know I can log a Slim framework easily with monolog:
$app->get(\'/tickets\', function
winston is a popular library for logging.
You can transport all logs to one file or keep different files for error, debug and info logs.
Example:
var winston = require('winston');
var logger = new winston.Logger({
level: 'error',
transports: [
new (winston.transports.File)({ filename: 'error.log' })
]
});
In the code:
logger.log('error', 'test error message %s', 'my string');
You can also use winston daily rotate file with winston to rotate your log files based on size or date.