eclipse / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
8.93k stars 2.37k forks source link

logging file size #2149

Open psatkun opened 3 years ago

psatkun commented 3 years ago

I've instituted logging in mosquitto.conf and mosquitto.log seems to grow to very large sizes if the broker is open for several days (1+ GB) - is there any method currently of archiving log files by limiting log sizes to a specific amount? I'm a Windows user and thus don't have the ability to use logrotate.d from Linux platforms.

ralight commented 3 years ago

There is support in Windows for signalling Mosquitto to reload using a named event. This will close and reopen the log file. I'm afraid I'm not sure of the best way to send that named event though. The name is mosq<pid>_reload, where <pid> is the program id of Mosquitto. There do seem to be some tools for log rotation on Windows... but I can't say anything about whether they are any use here.

Sorry, this isn't a very useful reply!

psatkun commented 3 years ago

Would it be possible to expose the reload signal to a command line argument that I could possibly call from a batch file or something like that?

ralight commented 3 years ago

Yes... it seems like this should be fairly straightforward now I've spent a while looking into it.

sfphh4 commented 3 years ago

I have a very different view of the logging. I dont think logging should be a part of Mosquitto config at all.

I think logging should be handled by the orchestration tool, such as pm2 or supervisorctl or docker, so any log rotation, or limiting should be done by them, and not be a problem that is handled at the level of Mosquitto.

I am fortified in my view by this: https://12factor.net/logs

psatkun commented 3 years ago

@ralight was this included in the latest release (2.0.10)? or is it still maybe coming up in the future?

SunSDSE commented 2 years ago

It would be good if the container supported "logrotate" or at least the ability to restart it to permit logrotate to restart the process.