getLog Command

Log-Related Commands

With the getLog command you can return a list of the log categories available and then all the messages for those categories. This command was introduced in 1.9.2.

> db.adminCommand({getLog:"*|global|<cat>"})
Getting Categories

To get all possible log categories, pass getLog a "*" option.

> db.adminCommand({getLog:"*"})
{
    "names" : [
           "global",
           "rs",
           "startupWarnings" ],
    "ok" : 1
}

This output indicates that there are 3 log categories available: "global" (see below), replica set notices, and startup warnings.

"global" Category

The special "global" category includes all other categories. You can pass any category in to limit the returned lines.

 
> db.adminCommand({getLog:"global"})
{
    "log" : [
        "Thu Aug 18 13:57:05 [initandlisten] MongoDB starting : pid=654312892 port=27017 dbpath=/tmp/db1/ 64-bit host=localnose",
        "Thu Aug 18 13:57:05 [initandlisten] recover : no journal files present, no recovery needed",
        "Thu Aug 18 13:57:07 [websvr] admin web console waiting for connections on port 28017",
        "Thu Aug 18 13:57:07 [initandlisten] waiting for connections on port 27017",
        "Thu Aug 18 13:57:07 [initandlisten] connection accepted from 127.0.0.1:56703 #1",
        "Thu Aug 18 13:57:07 [rsStart] replSet STARTUP2",
        "Thu Aug 18 13:57:07 [rsSync] replSet SECONDARY",
        "Thu Aug 18 13:57:10 [initandlisten] connection accepted from 127.0.0.1:56704 #2"
    ],
    "ok" : 1
}

Follow @mongodb

MongoDB Pittsburgh - May 15
MongoNYC - May 23
MongoDB Paris - Jun 14
MongoDB UK - Jun 20
MongoDC - June 26


Labels

getlog getlog Delete
command command Delete
commands commands Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.

blog comments powered by Disqus