Disabling and Enabling Logging for MongoDB Instances

Article ID: 59309

Article Type: Troubleshooting

Last Modified:

This article outlines the process for enabling or disabling logging for MongoDB instances installed with the Commvault software on a Windows computer.

Symptoms

The MongoDB log files (MongoDB.log or InstallMongoDB.log) experience an exponential growth in size, or do not actively log any MongoDB issues.

Resolution

Starting with Service Pack 19, MongoDB logging will be disabled by default to prevent log files from bloating up. To enable or disable logging for MongoDB, complete the following steps: Note: Before you disable or enable logging, you must be aware of the MongoDB service in the Windows Service Manager and in the Commvault ContentStore Process Manager. You must also know if your MongoDB service includes a config file that stores all the configuration parameters. To identify if your MongoDB service includes a config file, complete the following steps:

Disabling Logging for the MongoDB Instance

To disable logging for your MongoDB instance, complete the following steps:

  1. Stop the MongoDB service.
    • On the Windows Service Manager window, right-click the Commvault MongoDB(InstanceXXX) instance, and then select Stop.
  2. Disable logging for the MongoDB service.
    • Case 1: If the MongoDB service is running without a config file, the MongoDB server does not allow you to disable logging. Instead, you can configure the MongoDB service to roll over its log file on service restart. To trigger the log file rollover, update the following config parameters and then reinstall the service using a --reinstall command to reflect the configuration changes to the service.
      1. On the path to the executable, remove the config parameter --logappend, add the config parameters --servicename and --serviceDisplayName (you can obtain these parameters from the service property in Windows Service Manager), and then add the --reinstall parameter. The revised path to the executable should look as follows: "<Path-To-MongoDB>\bin\mongod.exe" --serviceName GxMONGO(InstanceXXX) --serviceDisplayName "<display-name>" --port <port-num> --dbpath "<DB-Path>" --logpath "<Log-Path>" --auth --noscripting --bind_ip localhost,<hostname> --service --reinstall
      2. Open the command prompt in Administrator mode, and then run the revised path to the executable.
    • Case 2: If the MongoDB service is running with a config file, disable logging using the following steps:
      1. Open the config file (cvmongod.cfg) in a text editor in Administrator mode. You can obtain the location of the config file from the service command.
      2. Replace the value for parameter [systemLog:path] with "" (empty string within quotes).
      3. Save and close the config file.
  3. Start the MongoDB service.
    1. If the MongoDB server is running without a config file, close and re-open the Windows Service Manager to verify that your path to the executable now reflects the updated config parameters.
    2. Right-click the Commvault MongoDB(InstanceXXX) instance, and then select Start.
  4. Verify that logging is disabled.
    • Open GxTail.exe, and then load the InstallMongoDB.log or MondoDB.log file. Verify that there are no new log lines after starting the MongoDB service.

Enabling Logging for the MongoDB Instance

To enable logging for your MongoDB instance, complete the following steps:

  1. Stop the MongoDB service.
    • On the Windows Service Manager window, right-click the Commvault MongoDB(InstanceXXX) instance, and then select Stop.
  2. Enable logging for the MongoDB service.
    • Case 1: If the MongoDB service is running without a config file, update the following config parameters and then reinstall the service using a --reinstall command to reflect the configuration changes to the service.
      1. On the startup service command, add the config parameters --logpath and --logappend, add the config parameters --servicename and --serviceDisplayName (you can obtain these parameters from the service property in Windows Service Manager), and then add the --reinstall parameter. The revised startup command should look as follows: "<Path-To-MongoDB>\bin\mongod.exe" --serviceName GxMONGO(InstanceXXX) --serviceDisplayName "<display-name>" --port <port-num> --dbpath "<DB-Path>" --logpath "<Log-Path>" --logappend --auth --noscripting --bind_ip localhost,<hostname> --service --reinstall
      2. Open the command prompt in Administrator mode, and then run the revised startup command.
    • Case 2: If the MongoDB service is running with a config file, enable logging using the following steps:
      1. Open the config file (cvmongod.cfg) in a text editor in Administrator mode. You can obtain the location of the config file from the path to the executable (should end with cvmongod.cfg).
      2. Replace the value for parameter [systemLog:path] with "<Log-Path>" (Path to the MongoDB.log file). Note: You must provide a valid log path with forward slashes (/) only. For example, "C:/Program Files/Commvault/ContentStore/Log Files/mongodb.log".
      3. Save and close the config file.
  3. Start the MongoDB service.
    1. If the MongoDB server is running without a config file, close and re-open the Windows Service Manager to verify that your path to the executable now reflects the updated config parameters.
    2. Right-click the Commvault MongoDB(InstanceXXX) instance, and then select Start.
  4. Verify that logging is enabled.
    • Open GxTail.exe, and then load the InstallMongoDB.log or MondoDB.log file. Verify if new log lines are printed after starting the MongoDB service.
1 Commvault Way, Tinton Falls, NJ 07724 Sitemap | Legal Notices | Trademarks | Privacy Policy
Copyright © 2022 Commvault | All Rights Reserved.