(debian-policy.info)Log files


Next: Permissions and owners Prev: Configuration files Up: Files<2>
Enter node , (file) or (file)node

10.8 Log files
==============

Log files should usually be named ‘/var/log/package.log’.  If you have
many log files, or need a separate directory for permission reasons
(‘/var/log’ is writable only by ‘root’), you should usually create a
directory named ‘/var/log/package’ and place your log files there.

Log files must be rotated occasionally so that they don’t grow
indefinitely.  The best way to do this is to install a log rotation
configuration file in the directory ‘/etc/logrotate.d’, normally named
‘/etc/logrotate.d/package’, and use the facilities provided by
‘logrotate’.  (1) Here is a good example for a logrotate config file
(for more information see logrotate(8)):

     /var/log/foo/*.log {
         rotate 12
         weekly
         compress
         missingok
         postrotate
             start-stop-daemon -K -p /var/run/foo.pid -s HUP -x /usr/sbin/foo -q
         endscript
     }

This rotates all files under ‘/var/log/foo’, saves 12 compressed
generations, and tells the daemon to reopen its log files after the log
rotation.  It skips this log rotation (via ‘missingok’) if no such log
file is present, which avoids errors if the package is removed but not
purged.

Log files should be removed when the package is purged (but not when it
is only removed).  This should be done by the ‘postrm’ script when it is
called with the argument ‘purge’ (see Note: Details of removal and/or
configuration purging.).

   ---------- Footnotes ----------

   (1) The traditional approach to log files has been to set up `ad hoc'
log rotation schemes using simple shell scripts and cron.  While this
approach is highly customizable, it requires quite a lot of sysadmin
work.  Even though the original Debian system helped a little by
automatically installing a system which can be used as a template, this
was deemed not enough.

The use of ‘logrotate’, a program developed by Red Hat, is better, as it
centralizes log management.  It has both a configuration file
(‘/etc/logrotate.conf’) and a directory where packages can drop their
individual log rotation configurations (‘/etc/logrotate.d’).


automatically generated by info2www version 1.2.2.9