[Bug] mongod.log is not rotated

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.

[Bug] mongod.log is not rotated

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.
[Bug] mongod.log is not rotated
[Bug] mongod.log is not rotated
2020-01-29 22:51:07

Hi,

 

I notice, that while server.log is rotated daily, mongod.log is not.

 

The mongod documentation mentions that this can be achieved by sending SIGUSR1 to the mongod process.

This looks like this then

 

# kill -SIGUSR1 $(pidof mongod)

-rw-r--r--  1 omada omada    71 Jan 29 22:47 mongod.log
-rw-r--r--  1 omada omada 34063 Jan 29 22:46 mongod.log.2020-01-29T22-47-06

 

# ls -la logs/
total 60
drwxr-xr-x  2 omada omada  4096 Jan 29 22:49 ./
drwxr-xr-x 11 root  root   4096 Jan 27 04:23 ../
-rw-r--r--  1 omada omada    71 Jan 29 22:49 mongod.log
-rw-r--r--  1 omada omada 34063 Jan 29 22:46 mongod.log.2020-01-29T22-47-06
-rw-r--r--  1 omada omada    71 Jan 29 22:47 mongod.log.2020-01-29T22-49-47

 

 

  0      
  0      
#1
Options
6 Reply
Re:[Bug] mongod.log is not rotated
2020-01-29 23:39:14 - last edited 2020-01-29 23:59:52

Hi ASCII,

 

mongod.log should be rotated according to the mongod.properties in Omada controller, but I'm not sure whether it works as expected:

 

#limit the size of mongodb log, unit is MB.
eap.mongod.log.size.limit=512
eap.mongod.log.rolling.size=50

 

Anyway, I prefer to place all logfiles (server.log, startup.log and mongod.log) under /var/log/ to where they belong to on Linux systems and to use the existing logrotate mechanism for rotation.

 

Doing so allows customization of rotation, archiving, cleanup and even mailing of logfiles in a standard way using simple scripts for the logrotate program. It's even possible to append timestamps to rotated logfiles much like mongod does. In my opinion there is no need for developers to implement all those functions in each and every daemon program if they only would obey the UNIX principle »Don't re-invent the wheel again«.

 

Only problem is that Omada controller's own rotation for the server.log interferes with logrotate to a certain extend. So, Omada controller actually did not only re-invent the wheel, but also added kind of a brake for an existing wheel (unless its built-in rotation can be disabled what I could not yet figure out how to do). :-)
 

 

༺ 0100 1101 0010 10ཏ1 0010 0110 1010 1110 ༻
  0  
  0  
#2
Options
Re:[Bug] mongod.log is not rotated
2020-01-30 00:06:45

@R1D2 thanks for the hint regarding mongod.properties. I'll give this a try. My log file hasn't reached 512MB yet, I'll probably set this to something lower.

 

For better or worse, I'm using omada controller inside a docker container. I don't have syslog, cron or logrotate running inside this container.

  0  
  0  
#3
Options
Re:[Bug] mongod.log is not rotated
2020-01-30 00:09:33

 

R1D2 wrote

Anyway, I prefer to place all logfiles ( server.log , startup.log and mongod.log ) under /var/log/ to where they belong to on Linux systems and to use the existing logrotate mechanism for rotation.

 

Doing so allows customization of rotation, archiving, cleanup and even mailing of logfiles in a standard way using simple scripts for the logrotate program. It's even possible to append timestamps to rotated logfiles much like mongod does. In my opinion there is no need for developers to implement all those functions in each and every daemon program if they only would obey the UNIX principle »Don't re-invent the wheel again«.

 

Only problem is that Omada controller's own rotation for the server.log interferes with logrotate to a certain extend. So, Omada controller actually did not only re-invent the wheel, but also added kind of a brake for an existing wheel (unless its built-in rotation can be disabled what I could not yet figure out how to do). :-)
 

 

@R1D2 It seems like you want an option where mongodb and the controller log via syslog, which shouldn't be to hard to implement, given that the omada controller already has some built in functionality to log to a remote syslog (although this syslog seems incomplete, it doesn't match what I get in server.log).

  0  
  0  
#4
Options
Re:[Bug] mongod.log is not rotated
2020-01-30 00:21:27 - last edited 2020-01-30 00:30:27

 

ASCII wrote 

It seems like you want an option where mongodb and the controller log via syslog, which shouldn't be to hard to implement, given that the omada controller already has some built in functionality to log to a remote syslog (although this syslog seems incomplete, it doesn't match what I get in server.log).

 

Indeed, I was able to redirect error and some logging message from Omada controller to the syslog daemon when using start-stop-daemon to run EAP controller V2.x. It's one of the standard features of start-stop-daemon. jsvc can't do this.

 

And yes, I did suggest this to TP-Link's R&D already several times in last 3 years to use syslog internally, but they decided to not use it.

There is nothing wrong using own logfiles, but my own software lets users choose any logging style: own logfiles, syslogd or even stderr.

 

By using syslogd the Java code for sending logs to a remote host could be completely removed in Omada controller. 

 

And by using the system's mongodb package instead of bundling it with Omada controller there would be even more freedom to choose from features of mongod. The community version of Omada controller uses the system's mongodb package, but still requires a separate instance for Omada controller, so if mongod is already used for other databases, there will be two mongod instances running at the end.

 

Albeit one can define the ports to use for communication of Omada controller with mongod, it's not possible to remove the built-in test whether mongod is running after it has been started by Omada controller. I even was thinking about writing a fake mongod tunnel server for Omada controller, which forwards requests to the system's mongod, thus requiring just one database server instance running.
But hey, I still have a life beside Omada controller. :-)

 

That's why I requested to fully use the system's mongodb package in the last feature request. mongod can handle more than only one database.

༺ 0100 1101 0010 10ཏ1 0010 0110 1010 1110 ༻
  0  
  0  
#5
Options
Re:[Bug] mongod.log is not rotated
2020-01-30 01:04:23

@R1D2 I'm with you here. I don't really like that omada controller comes with a bundled version of mongodb which is 8 years old. It's ok to ship a tarball which comes bundled with all dependencies, but it should be possible to configure omada to use a system provided mongodb (which can be upgraded independently).

The same goes for the bundled jre (which is 2 years old).

 

 

  0  
  0  
#6
Options
Re:[Bug] mongod.log is not rotated
2020-01-30 17:52:23

@ASCII, the community version uses standard packages for mongodb and Oracle JRE, but I haven't tested it with latest versions. I still run Debian Jessie for various reasons / dependencies. I had no luck to get Omada controller running with latest JRE one year ago, so I still use JRE 8, albeit a later patch level than what comes with the official Omada controller.

 

Maybe you have time to check out compatibility with latest JRE? If so, please give feedback here in the forum.

༺ 0100 1101 0010 10ཏ1 0010 0110 1010 1110 ༻
  0  
  0  
#7
Options