Search code examples
archiversysloglogrotatelog-rotation

rsyslog dynamic filename log rotation


All hosts are sending all logs to RSyslog server (ver 5.8.10).

RSyslog uses the following template to save log files -

$template RemoteHost,"/var/log/x/host/%$YEAR%-%$MONTH%-%$DAY%/%HOSTNAME%/%APP-NAME%.log"

So windows event log from host11 will be logged to - /var/log/x/host/2013-09-24/host11/EvntSLog.log

I would now like to setup logrotate such that and entire day's worth of log files is zipped-up and sent to '/nfs/archive/'. So the above log file when archived should look like this - /nfs/archive/2013-09-24.tgz. Note here that i am not zipping up individual log files, i am zipping up an entire directory.

How can i achieve this using logrotate/cron ?


Solution

  • For now, i have decided to do this with a python script that zips everything up and copies it over to a nfs partition. If someone has managed to implement this using logrotate, please respond to this thread.