We've setup a NodeJS server for our API, and are currently logging all incoming requests to a file using morgan. In addition to the file-logging, we would also like to store the requests in mongodb (preferably without having to use mongoose). Any help would be greatly appreciated :) thanks!
You can use mongoose-morgan or just integrate morgan
with winston
and winston-mongodb .
const morgan = require('morgan');
const winston = require('winston');
require('winston-mongodb');
app.user(morgan('combined', {stream: new winston.transports.MongoDB({db: /*mongodb-uri*/}).stream()}));
You can see transport options here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.