Notification log rotate questions

Hi all,

I have some questions about notification.log rotation,

  1. How does Mattermost rename the original log files during log rotation?
  2. Will the newly generated log files overwrite or replace the original log files after log rotation?

Thanks in advance.

Hi @YiruChen ,

see this code for details:

Files will be rotated if they reach 100MB in size and will have the timestamp of when the rotation took place added to their name. Afterwards, they will be compressed.

This is what the contents of my log folder looks like right now:

-rw-r--r-- 1 mattermost mattermost  11M Mar 27 12:36 notifications-2023-03-27T10-36-30.148.log.gz
-rw-r--r-- 1 mattermost mattermost  11M Apr  3 19:13 notifications-2023-04-03T17-13-17.959.log.gz
-rw-r--r-- 1 mattermost mattermost  11M Apr 12 15:46 notifications-2023-04-12T13-46-52.236.log.gz
-rw-r--r-- 1 mattermost mattermost 3.9M Apr 13 06:26 notifications.log

The notification.log file will be moved to the new filename, then the server process gets a signal to start writing to a new logfile and then the renamed file will be compressed.

Hi @agriesser

So the specific steps of the rotation process are as like:

  1. The notification.log file will be moved to a new filename with a timestamp, for example, notifications-2023-03-27T10-36-30.148.log.
  2. The server process will receive a signal to start writing to a new log file (a new file notification.log will be generated), which will continue recording logs as usual.
  3. The original file that was renamed (e.g., notifications-2023-03-27T10-36-30.148.log) will be compressed, generating a new compressed file (e.g., notifications-2023-03-27T10-36-30.148.log.gz) to save disk space.

Is this correct?

Thanks again!

Yes, that’s correct.

Hi @agriesser

Are both files mattermost.log and notifications.log rotated to the same file?

Hi @thanhbui723 and welcome to the Mattermost forums!

No, each file will keep its name and only the date will be added as a suffix to the filename - I hope I understood your question right, if not, please try to rephrase.

I understand. Thanks

Hi @agriesser
Can I upload file logs to AWS S3 ?

I don’t think that this is possible, at least not natively in Mattermost. You could write some small scripts that sync the local logs directory with an S3 bucket and delete the rotated files locally then.

Oh. Good idea! Thank you so much.