The following sections show the configurations needed to create a syslog server with log rotation. Rsyslog and syslog-ng have both been included in the examples.
=== /etc/rsyslog.conf === $ModLoad immark $ModLoad imudp $UDPServerRun 514 $ModLoad imtcp $InputTCPServerRun 514 $template FILENAME,"/var/log/rsyslog/%fromhost-ip%/messages.txt" *.* ?FILENAME # The following line must be commented out. #*.info;mail.none;authpriv.none;cron.none /var/log/messages $umask 0000 $DirCreateMode 0755 $FileCreateMode 0644
===
/etc/syslog-ng/syslog-ng.conf
===
source s_net {
tcp();
udp();
};
destination d_net { file("/var/log/syslog/$DAY/$HOST.txt" perm(0644) dir_perm(0755) create_dirs(yes)); };
log { source(s_net); destination(d_net); };
===
/etc/logrotate.conf
===
/var/log/rsyslog/*/messages.txt {
missingok
dateext
copytruncate
daily
rotate 21
extension .txt
}
/var/log/syslog/*/* {
daily
rotate 7
extention txt
}
==
/etc/httpd/conf/httpd.conf
==
Alias /syslog/ "/var/log/syslog/"
<Directory "/var/log/syslog">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>