myesn

myEsn2E9

hi
github

MongoDB: Enable, Disable, Filter, and View Query Logs

// Disable query logging (default)
db.setProfilingLevel(0)

// Enable query logging, with levels 0 (off), 1 (slow queries), or 2 (all queries)
db.setProfilingLevel(2)

// Enable query logging and configure maximum number of records
db.setProfilingLevel(2,0,100)

// Get the current query logging status
db.getProfilingStatus()

// Query logging (sorting, limit)
db.system.profile.find().sort({$natural:-1}).limit(50)

// Filter query logs based on conditions (latest records first)
db.system.profile.find({ op: "query", ns: "hospital-next.devices" }).sort({$natural:-1})

// Clear query logs
db.system.profile.drop()
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.