From 7c990bd7db2aa912f35c305899b56b1ae33bb8f6 Mon Sep 17 00:00:00 2001 From: Bagas Sanjaya Date: Sat, 18 Jan 2020 15:10:07 +0700 Subject: [PATCH 1/2] [Contrib] Logrotate config and docs --- contrib/logrotate/gitea.conf | 15 +++++++++ .../doc/usage/logrotate-setup.en-us.md | 32 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 contrib/logrotate/gitea.conf create mode 100644 docs/content/doc/usage/logrotate-setup.en-us.md diff --git a/contrib/logrotate/gitea.conf b/contrib/logrotate/gitea.conf new file mode 100644 index 0000000000000..850f83bac6cae --- /dev/null +++ b/contrib/logrotate/gitea.conf @@ -0,0 +1,15 @@ +# Rotate Gitea logs +# Replace path to logs if you use different working directory + +/var/lib/gitea/log/*.log, /var/lib/gitea/log/hooks/*.log { + daily + missingok + rotate 7 + compress + notifempty + create 0660 git git + sharedscripts + postrotate + systemctl restart gitea.service + endscript +} diff --git a/docs/content/doc/usage/logrotate-setup.en-us.md b/docs/content/doc/usage/logrotate-setup.en-us.md new file mode 100644 index 0000000000000..84757383ae77f --- /dev/null +++ b/docs/content/doc/usage/logrotate-setup.en-us.md @@ -0,0 +1,32 @@ +--- +date: "2020-01-19" +title: "Usage: Logrotate setup" +slug: "logrotate-setup" +weight: 12 +toc: true +draft: false +menu: + sidebar: + parent: "usage" + name: "Logrotate setup" + weight: 12 + identifier: "logrotate-setup" +--- + +## `logrotate` Setup + +The `logrotate` utility automates log rotation. This is especially useful for larger Gitea instance with many users and repositories, where Gitea logs can grow quickly. + +To use `logrotate`, install the package first. + +Then copy [sample configuration](https://github.com/go-gitea/gitea/blob/master/contrib/logrotate/gitea.conf) to `/etc/logrotate.conf.d` and edit it to fit your Gitea instance. + +As root, test the configuration by: + +``` +logrotate /etc/logrotate.conf --debug +``` + +Fix any errors if found. + +Please note that `logrotate` doesn't have restart command as its next rotation job includes any new configurations. From 115ca5d4af68f086697d12788d1a5d0aa649b238 Mon Sep 17 00:00:00 2001 From: Bagas Sanjaya Date: Mon, 20 Jan 2020 10:18:55 +0700 Subject: [PATCH 2/2] [Docs] Disable built-in log rotation before using logrotate --- docs/content/doc/usage/logrotate-setup.en-us.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/doc/usage/logrotate-setup.en-us.md b/docs/content/doc/usage/logrotate-setup.en-us.md index 84757383ae77f..1832b5d1d6d0a 100644 --- a/docs/content/doc/usage/logrotate-setup.en-us.md +++ b/docs/content/doc/usage/logrotate-setup.en-us.md @@ -17,7 +17,7 @@ menu: The `logrotate` utility automates log rotation. This is especially useful for larger Gitea instance with many users and repositories, where Gitea logs can grow quickly. -To use `logrotate`, install the package first. +To use `logrotate`, install the package first. Make sure to set `LOG_ROTATE` and `DAILY_ROTATE` on your `app.ini` to `false`, as `logrotate` will do the job instead of built-in rotation. See also [Config Cheat Sheet](https://docs.gitea.io/en-us/config-cheat-sheet/#file-log-mode-log-file-log-file-or-mode-file). Then copy [sample configuration](https://github.com/go-gitea/gitea/blob/master/contrib/logrotate/gitea.conf) to `/etc/logrotate.conf.d` and edit it to fit your Gitea instance.