Line 11: | Line 11: | ||
== Log Files Packaging == | == Log Files Packaging == | ||
... | |||
<pre> | <pre> | ||
Line 28: | Line 30: | ||
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}.conf | %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}.conf | ||
%dir %attr(0700,root,root) %{_localstatedir}/log/%{name} | %dir %attr(0700,root,root) %{_localstatedir}/log/%{name} | ||
</pre> | |||
Example logrotate file without daemon reload | |||
/var/log/example/*log { | |||
missingok # If the log file is missing, go on to the next one without issuing an error message | |||
notifempty # Don't do any rotation if the logfile is empty | |||
compress # Compress older files with gzip | |||
delaycompress # Don't compress yesterdays files | |||
sharedscripts # Scripts are only run once for all files in directory | |||
} | |||
Example logrotate file with user creation but without daemon reload | |||
/var/log/example/*log { | |||
missingok # If the log file is missing, go on to the next one without issuing an error message | |||
notifempty # Don't do any rotation if the logfile is empty | |||
compress # Compress older files with gzip | |||
delaycompress # Don't compress yesterdays files | |||
create 640 owner group # Set create mode immediately after rotation | |||
sharedscripts # Scripts are only run once for all files in directory | |||
} | |||
Example logrotate file with user creation and with daemon reload | |||
<pre> | |||
#Example logrotate file without daemon reload | |||
/var/log/example/*log { | |||
missingok # If the log file is missing, go on to the next one without issuing an error message | |||
notifempty # Don't do any rotation if the logfile is empty | |||
compress # Compress older files with gzip | |||
delaycompress # Don't compress yesterdays files | |||
sharedscripts # Scripts are only run once for all files in directory | |||
} | |||
Example logrotate file with user creation but without daemon reload | |||
/var/log/example/*log { | |||
missingok # If the log file is missing, go on to the next one without issuing an error message | |||
notifempty # Don't do any rotation if the logfile is empty | |||
compress # Compress older files with gzip | |||
delaycompress # Don't compress yesterdays files | |||
create 640 owner group # Set create mode immediately after rotation | |||
sharedscripts # Scripts are only run once for all files in directory | |||
} | |||
</pre> | |||
Example logrotate file with user creation and with daemon reload | |||
<pre> | |||
/var/log/example/*log { | |||
missingok # If the log file is missing, go on to the next one without issuing an error message | |||
notifempty # Don't do any rotation if the logfile is empty | |||
compress # Compress older files with gzip | |||
delaycompress # Don't compress yesterdays files | |||
create 640 owner group # Set create mode immediately after rotation | |||
sharedscripts # Scripts are only run once for all files in directory | |||
postrotate | |||
/usr/bin/systemctl restart example.service 2>/dev/null || true | |||
endscript | |||
} | |||
/var/log/example/*log { | |||
missingok # If the log file is missing, go on to the next one without issuing an error message | |||
notifempty # Don't do any rotation if the logfile is empty | |||
compress # Compress older files with gzip | |||
delaycompress # Don't compress yesterdays files | |||
create 640 owner group # Set create mode immediately after rotation | |||
sharedscripts # Scripts are only run once for all files in directory | |||
postrotate | |||
/usr/bin/systemctl restart example.service 2>/dev/null || true | |||
endscript | |||
} | |||
</pre> | </pre> |
Revision as of 11:42, 23 February 2012
Fedora Log Files
This document describes the guidelines for log file(s), for use and inclusion in Fedora packages.
Log Files on the filesystem
Packages with log files must reside in their own directory under /var/log which must be named /var/log/$package_name
Each log file in that directory must end with .log filename.
Each package that ships log files must also ship a logrotation file that rotates the log file(s).
Log Files Packaging
...
Name: ..... Source1: %{name}.logrotate Requires: logrotate %install ... mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log/%{name} mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d %{__install} -p -D -m 0700 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/%{name}.conf %files ... %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}.conf %dir %attr(0700,root,root) %{_localstatedir}/log/%{name}
Example logrotate file without daemon reload
/var/log/example/*log { missingok # If the log file is missing, go on to the next one without issuing an error message notifempty # Don't do any rotation if the logfile is empty compress # Compress older files with gzip delaycompress # Don't compress yesterdays files sharedscripts # Scripts are only run once for all files in directory }
Example logrotate file with user creation but without daemon reload
/var/log/example/*log { missingok # If the log file is missing, go on to the next one without issuing an error message notifempty # Don't do any rotation if the logfile is empty compress # Compress older files with gzip
delaycompress # Don't compress yesterdays files
create 640 owner group # Set create mode immediately after rotation sharedscripts # Scripts are only run once for all files in directory }
Example logrotate file with user creation and with daemon reload
#Example logrotate file without daemon reload /var/log/example/*log { missingok # If the log file is missing, go on to the next one without issuing an error message notifempty # Don't do any rotation if the logfile is empty compress # Compress older files with gzip delaycompress # Don't compress yesterdays files sharedscripts # Scripts are only run once for all files in directory } Example logrotate file with user creation but without daemon reload /var/log/example/*log { missingok # If the log file is missing, go on to the next one without issuing an error message notifempty # Don't do any rotation if the logfile is empty compress # Compress older files with gzip delaycompress # Don't compress yesterdays files create 640 owner group # Set create mode immediately after rotation sharedscripts # Scripts are only run once for all files in directory }
Example logrotate file with user creation and with daemon reload
/var/log/example/*log { missingok # If the log file is missing, go on to the next one without issuing an error message notifempty # Don't do any rotation if the logfile is empty compress # Compress older files with gzip delaycompress # Don't compress yesterdays files create 640 owner group # Set create mode immediately after rotation sharedscripts # Scripts are only run once for all files in directory postrotate /usr/bin/systemctl restart example.service 2>/dev/null || true endscript } /var/log/example/*log { missingok # If the log file is missing, go on to the next one without issuing an error message notifempty # Don't do any rotation if the logfile is empty compress # Compress older files with gzip delaycompress # Don't compress yesterdays files create 640 owner group # Set create mode immediately after rotation sharedscripts # Scripts are only run once for all files in directory postrotate /usr/bin/systemctl restart example.service 2>/dev/null || true endscript }