X
46

How to control the amount of logs stored by the Next-Gen License Server’s included MongoDB package

The NV5 Next-Gen License Server utilizes a third-party package called MongoDB Community Server which does not provide a mechanism for automatic deletion of its own older log files. As a result, the storage footprint of MongoDB’s log files will continue to grow and could result in filesystem capacity issues over time in some rare cases, especially those where storage is limited and there is a high volume of clients using the Next-Gen License Server.

The default log storage directories for MongoDB are as follows:

  • Windows: C:\Program Files\MongoDB\Server\6.0\log
  • Linux: /var/log/mongodb

However, this potential logging problem can be mitigated in two ways, described below.

 

Configuration to delete older MongoDB log files

WINDOWS

On Windows, the automatic deletion of old log files can be accomplished using Task Scheduler. Here are the basic steps:

NOTE: Administrator privileges required.

1) Open the system utility called Task Scheduler.

2) Under “Task Scheduler Library”, create a new folder called “Local”.

3) Inside this new folder, choose the option to “Create Task”

 

4) Configure the General and Triggers tab as shown below.

 

5) Configure the Actions tab as shown below.

Program/script: ForFiles

Arguments: /p "C:\Program Files\MongoDB\Server\6.0\log" /d -14 /c "cmd /c del /q @file"

Important Notes: Make sure to choose the correct version of MongoDB in the directory specified within the Arguments field. This will depend on your exact version of the Next-Gen License Server installed.

The number “14” here represents the amount of days that log files should be kept for. This can be changed to any desired value keeping in mind that larger numbers will increase the log storage footprint.

 

6) Configure the Conditions and Settings tabs as shown.

 

7) Click OK to create the task. Your automated task to delete the older log files should now run daily, only keeping log files that are newer than the specified number of days.

 

LINUX

On Linux, the automatic deletion of old log files can be accomplished by using the logrotate utility. Here are the basic steps:

NOTE: Sudo privileges required.

1) Install the logrorate utility (if not already installed):

sudo apt-get install logrotate

2) Create a file to manage MongoDB logs:

sudo nano /etc/logrotate.d/mongod

3) Add the following lines to the newly created file:

/var/log/mongodb/mongod.log {
     rotate 365
     compress
     daily
     missingok
     notifempty
     create 0640 mongodb mongodb
     sharedscripts
     postrotate
          /usr/bin/systemctl kill -s USR1 mongod
     endscript

 

This configuration will rotate the MongoDB log file daily, compress the old logs, and restart the MongoDB service after rotation to ensure it writes to the new log file

 

4)  You can verify the status of the log rotation using the following command:

sudo logrotate -d /etc/logrotate.conf

 

 

Configuration to disable MongoDB log file creation

WINDOWS

1) Edit the MongoDB configuration file (C:\Program Files\MongoDB\Server\6.0\bin\mongod.cfg), updating the path setting to be as follows:

# where to write logging data.
systemLog:
     destination: file
     logAppend: true
     #path:  C:\Program Files\MongoDB\Server\6.0\log\mongod.log
     path: C:\nul

 

2)  Save and close the file, then restart the MongoDB service to have the changes take effect.

 

LINUX

1) Edit the MongoDB configuration file (/etc/mongod.conf), updating the path setting to be as follows:

# where to write logging data.
systemLog:
     destination: file
     logAppend: true
     #path: /var/log/mongodb/mongod.log
     path: /dev/null

 

2) Save and close the file, then restart the MongoDB service to have the changes take effect.

 

 

 

Created by BC-US 1/29/2025, Reviewed by XX X/XX/XXXX