node.jsmongodbmongoosemorgan

mongoose-morgan without GET request logging


Hey In my project I'm using mongoose-morgan.It is logging all the GET,POST,PUT and DELETE requests.But I want not to log GET requests.(Due to Higher number of GET requests).Is there a way to do that?

const mongooseMorgan = require("mongoose-morgan");


app.use(
    mongooseMorgan({
        connectionString: db.url,
    })
);

Solution

  • Use skip

    Read - https://github.com/nemanjapetrovic/mongoose-morgan#detailed-usage

    app.use(
        mongooseMorgan(
            {
                connectionString: db.url,
            },
            {
               skip: function (req, res) { return req.method === "GET" }
            }
        )
    );