Feature #2053

Implement configurable log rotation and retention policies

Added by Filippo Carletti about 8 years ago. Updated almost 8 years ago.

Status:CLOSEDStart date:
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:nethserver-base
Target version:v6.4-beta2
Resolution: NEEDINFO:No

Description

By default logs are rotated weekly and kept for 4 weeks.
Some packages come with different defaults, but the majority do not specify a custom rotate value.
I'd prefer to keep log files for more than 4 weeks, maybe 3 or 6 months, but a db property to set custom values should be preferred.
A custom value of 0 to not retain logs should be tested.

Associated revisions

Revision 2d71a626
Added by Giacomo Sanchietti almost 8 years ago

createlinks, templates: add configurable default log retention and rotation policies. Refs #2053

History

#1 Updated by Giacomo Sanchietti about 8 years ago

  • Subject changed from Log rotation and retention to Implement configurable log rotation and retention policies

#2 Updated by Giacomo Sanchietti almost 8 years ago

  • Status changed from NEW to TRIAGED
  • % Done changed from 0 to 20
We could add /etc/logrotate.conf template to nethserver-base and add two simple configurations:
  • # of weeks for retention
  • enable/disable log compression

#4 Updated by Giacomo Sanchietti almost 8 years ago

  • Status changed from TRIAGED to ON_DEV
  • Assignee set to Giacomo Sanchietti
  • % Done changed from 20 to 30

#5 Updated by Giacomo Sanchietti almost 8 years ago

  • Status changed from ON_DEV to MODIFIED
  • % Done changed from 30 to 60
Implementation:
  • added template for /etc/logrotate.conf
  • added event logrotate-update

Keep log for 6 months, rotate every week:

config setprop logrotate Rotate weekly
config setprop logrotate Times 24
signal-event logrotate-update

Do not keep any old log, rotate very day:

config setprop logrotate Rotate daily
config setprop logrotate Times 0
signal-event logrotate-update

#6 Updated by Giacomo Sanchietti almost 8 years ago

  • Status changed from MODIFIED to ON_QA
  • Assignee deleted (Giacomo Sanchietti)
  • % Done changed from 60 to 70
New package in nethserver-testing:
  • nethserver-base-1.4.1-3.0git2d71a626.ns6.noarch.rpm
Test case
  • Change default retention and rotation policies
  • Check /etc/logorate.conf is changed accordingly

To force logrotate:

logrotate -f /etc/logrotate.conf

For more information see: nethserver-base

Attention: logrotate will not delete old rotated logs after changing Times property.

#7 Updated by Davide Principi almost 8 years ago

  • Assignee set to Davide Principi

#8 Updated by Davide Principi almost 8 years ago

  • Status changed from ON_QA to VERIFIED
  • Assignee deleted (Davide Principi)
  • % Done changed from 70 to 90

VERIFIED

   # date
Tue Oct 15 10:55:33 GMT 2013
   # find /var/log/ | grep -e '-[0-9]'
/var/log/httpd/admin_error_log-20131015
/var/log/httpd/admin_access_log-20131015
/var/log/spooler-20131015
/var/log/cron-20131015
/var/log/btmp-20131015
/var/log/messages-20131015
/var/log/maillog-20131015
/var/log/secure-20131015
   # config setprop logrotate Rotate daily Times 2
   # config show logrotate
logrotate=configuration
    Compression=disabled
    Rotate=daily
    Times=2
   # signal-event logrotate-update
   # date -u 10161302
Wed Oct 16 13:02:00 UTC 2013
   # logrotate -f /etc/logrotate.conf
   # find /var/log/ | grep -e '-[0-9]' | sort
/var/log/btmp-20131016
/var/log/cron-20131015
/var/log/cron-20131016
/var/log/dracut.log-20131016
/var/log/httpd/admin_access_log-20131015
/var/log/httpd/admin_error_log-20131015
/var/log/maillog-20131015
/var/log/maillog-20131016
/var/log/messages-20131015
/var/log/messages-20131016
/var/log/secure-20131015
/var/log/secure-20131016
/var/log/shorewall-init.log-20131016
/var/log/spooler-20131015
/var/log/spooler-20131016
/var/log/squid/access.log-20131016.gz
/var/log/squid/cache.log-20131016.gz
/var/log/wtmp-20131016
/var/log/yum.log-20131016
    # date -u 10171302
Thu Oct 17 13:02:00 UTC 2013
    # logrotate -f /etc/logrotate.conf
    # find /var/log/ | grep -e '-[0-9]' | sort
/var/log/btmp-20131017
/var/log/cron-20131016
/var/log/cron-20131017
/var/log/dracut.log-20131016
/var/log/httpd/admin_access_log-20131015
/var/log/httpd/admin_error_log-20131015
/var/log/maillog-20131016
/var/log/maillog-20131017
/var/log/messages-20131016
/var/log/messages-20131017
/var/log/secure-20131016
/var/log/secure-20131017
/var/log/shorewall-init.log-20131016
/var/log/spooler-20131016
/var/log/spooler-20131017
/var/log/squid/access.log-20131016.gz
/var/log/squid/cache.log-20131016.gz
/var/log/squid/cache.log-20131017.gz
/var/log/wtmp-20131017
/var/log/yum.log-20131016

/etc/logrotate.conf diffs

--- logrotate.1    2013-10-15 10:59:50.798894195 +0000
+++ logrotate.2    2013-10-15 11:00:00.351555498 +0000
@@ -10,11 +10,11 @@
 # http://www.nethesis.it - support@nethesis.it
 # 
 # see "man logrotate" for details
-weekly
+daily

 # keep 4 times worth of backlogs
-rotate 4
+rotate 2

#9 Updated by Giacomo Sanchietti almost 8 years ago

  • Status changed from VERIFIED to CLOSED
  • % Done changed from 90 to 100
In nethserver-updates:
  • nethserver-base-1.4.3

Also available in: Atom PDF