How to enable detailed debug logging in MongoDB

Version 1
    Share:|

    This document contains official content from the BMC Software Knowledge Base. It is automatically updated when the knowledge article is modified.


    PRODUCT:

    Remedy with Smart IT


    APPLIES TO:

    All versions



    QUESTION:

    Mongo logging does not show any detail of activity when queries/inserts are performed by Smart IT/Social Service. How can we control the logging produced in the mongo log file?


    ANSWER:

    Mongo provides the ability to control the log level for various features independently.

    To control the precise log level MongoDb produces in the mongod log file, we need to log into MongoDb using the mongo shell and call the 'setLogLevel()' function to
    set the logging level for the feature of interest.

    Here is an example, setting the 'query' feature to the highest log level, debug (5):-

    C:\Program Files\BMC Software\Smart_IT_MyIT\Smart_IT_MyIT\mongodb\bin>mongo

    MongoDB shell version: 3.0.6
    connecting to: test
    > use social
    switched to db social
    > db.setLogLevel(5, "query")
    {
            "was" : {
                    "verbosity" : 0,
                    "accessControl" : {
                            "verbosity" : -1
                    },
                    "command" : {
                            "verbosity" : -1
                    },
                    "control" : {
                            "verbosity" : -1
                    },
                    "geo" : {
                            "verbosity" : -1
                    },
                    "index" : {
                            "verbosity" : -1
                    },
                    "network" : {
                            "verbosity" : -1
                    },
                    "query" : {
                            "verbosity" : 5       <=== new log level
                    },
                    "replication" : {
                            "verbosity" : -1
                    },
                    "sharding" : {
                            "verbosity" : -1
                    },
                    "storage" : {
                            "verbosity" : -1,
                            "journal" : {
                                    "verbosity" : -1
                            }
                    },
                    "write" : {
                            "verbosity" : -1
                    }
            },
            "ok" : 1
    }
    >


    NOTE: Log level 5 is very detailed and perhaps 1-3 are more useful options unless you really need all of the detailed internal information provided by this highest log level.

    Generally, setting the following to 1 tends to provide sufficient information to investigate most SmartIT/MyIT issues in Mongo:-

    >db.setLogLevel(1, "query")
    >db.setLogLevel(1, "write")
    >db.setLogLevel(1, "command")

    Once you have gathered the required log, we can turn off debug logging for all options again:-

    >db.setLogLevel(0)

    NOTE: If you do not specify a feature, then the log level will be set for all options.


    Generally it is helpful to include debug Social logging when gathering mongo logs:-
    - In SmartIT/MyIT Social/config.js .. we should enable debug logging
    - In SmartIT/MyIT Social/server.js .. we should uncomment the 'mongoose.set("debug", true)' line
    - Stop the SmartIT/MyIT Tomcat and Social services.
    - Start the Social Server first and then start the Smart IT/MyIT Tomcat.
     


    Article Number:

    000146763


    Article Type:

    FAQ/Procedural



      Looking for additional information?    Search BMC Support  or  Browse Knowledge Articles