# Notification log rotate questions

**URL:** <https://forum.mattermost.com/t/notification-log-rotate-questions/15660>\
**Category:** Troubleshooting\
**Created:** [April 13, 2023, 4:12am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660 "2023-04-13T04:12:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![YiruChen](https://avatars.discourse-cdn.com/v4/letter/y/3ab097/32.png) [@YiruChen](https://forum.mattermost.com/u/YiruChen)\
**Post date:** [April 13, 2023, 4:12am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660/1 "2023-04-13T04:12:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![agriesser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agriesser/32/5644_2.png) [@agriesser](https://forum.mattermost.com/u/agriesser)\
**Post date:** [April 13, 2023, 4:28am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660/2 "2023-04-13T04:28:31Z")

</div>

Hi @YiruChen ,

see this code for details:

> <https://github.com/mattermost/mattermost-server/blob/master/server/config/logger.go#L17>

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:

```auto
-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.

---

<div class="post-metadata">

**Author:** ![YiruChen](https://avatars.discourse-cdn.com/v4/letter/y/3ab097/32.png) [@YiruChen](https://forum.mattermost.com/u/YiruChen)\
**Post date:** [April 13, 2023, 5:31am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660/3 "2023-04-13T05:31:03Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![agriesser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agriesser/32/5644_2.png) [@agriesser](https://forum.mattermost.com/u/agriesser)\
**Post date:** [April 14, 2023, 3:32am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660/4 "2023-04-14T03:32:32Z")

</div>

Yes, that’s correct.

---

<div class="post-metadata">

**Author:** ![thanhbui723](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/thanhbui723/32/6833_2.png) [@thanhbui723](https://forum.mattermost.com/u/thanhbui723)\
**Post date:** [May 22, 2023, 9:14am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660/5 "2023-05-22T09:14:55Z")

</div>

Hi @agriesser

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

---

<div class="post-metadata">

**Author:** ![agriesser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agriesser/32/5644_2.png) [@agriesser](https://forum.mattermost.com/u/agriesser)\
**Post date:** [May 22, 2023, 9:16am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660/6 "2023-05-22T09:16:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![thanhbui723](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/thanhbui723/32/6833_2.png) [@thanhbui723](https://forum.mattermost.com/u/thanhbui723)\
**Post date:** [May 22, 2023, 9:19am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660/7 "2023-05-22T09:19:30Z")

</div>

I understand. Thanks

---

<div class="post-metadata">

**Author:** ![thanhbui723](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/thanhbui723/32/6833_2.png) [@thanhbui723](https://forum.mattermost.com/u/thanhbui723)\
**Post date:** [May 24, 2023, 8:22am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660/8 "2023-05-24T08:22:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![agriesser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agriesser/32/5644_2.png) [@agriesser](https://forum.mattermost.com/u/agriesser)\
**Post date:** [May 24, 2023, 9:07am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660/9 "2023-05-24T09:07:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![thanhbui723](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/thanhbui723/32/6833_2.png) [@thanhbui723](https://forum.mattermost.com/u/thanhbui723)\
**Post date:** [May 24, 2023, 9:16am UTC](https://forum.mattermost.com/t/notification-log-rotate-questions/15660/10 "2023-05-24T09:16:00Z")

</div>

Oh. Good idea! Thank you so much.
