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:
On the Windows Service Manager window, right-click the MongoDB service and copy the entire path to the executable into a text editor.
Case 1: If the MongoDB service is running without a config file, the path to the executable will use the following template:
"<Path-To-MongoDB>\bin\mongod.exe" -port <port-num> --dbpath "<DB-Path>" --logpath "<Log-Path>" --logappend --auth --noscripting --bind_ip localhost,<hostname> --service
Case 2: If the MongoDB service is running with a config file, the path to the executable will use the following template:
"<Path-To-MongoDB>\bin\mongod.exe" --config "<Config-File-Location>"
Disabling Logging for the MongoDB Instance
To disable logging for your MongoDB instance, complete the following steps:
Stop the MongoDB service.
On the Windows Service Manager window, right-click the Commvault MongoDB(InstanceXXX) instance, and then select Stop.
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.
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
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:
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.
Replace the value for parameter [systemLog:path] with "" (empty string within quotes).
Save and close the config file.
Start the MongoDB service.
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.
Right-click the Commvault MongoDB(InstanceXXX) instance, and then select Start.
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:
Stop the MongoDB service.
On the Windows Service Manager window, right-click the Commvault MongoDB(InstanceXXX) instance, and then select Stop.
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.
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
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:
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).
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".
Save and close the config file.
Start the MongoDB service.
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.
Right-click the Commvault MongoDB(InstanceXXX) instance, and then select Start.
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.