View Full Version : renaming a syslog log file in the current date format
coolatt
January 14th, 2009, 07:53
hi !
plz help with configuring syslog to write to a new log file(file name format must be YY-MM-DD) everyday
thx.
SirDice
January 14th, 2009, 08:03
AFAIK neither syslog nor newsyslog is able to do that. You will need to create a script that does this.
coolatt
January 14th, 2009, 09:25
plz explain how to do that.
just renaming the file which is currently in use by syslogd will be ok so that it stops writing to it ?
coolatt
January 14th, 2009, 09:28
but can syslog-ng do that ?
DutchDaemon
January 14th, 2009, 10:15
I don't think that either syslog nor syslog-ng, nor newsyslog, nor logrotate, handle renaming or creating logfiles with timestamps or something like that. An option would be to tell newsyslog to rotate every single logfile at midnight, and then have a local script rename every *.0.bz2 (or *.0.gz) to *.`date -v-1d +%Y%m%d`.bz2 (or .gz, whatever). This does cause a lot of clutter in /var/log, so you might want to move things out of the way to /var/log/month/ or /var/log/week.
coolatt
January 14th, 2009, 10:38
Thanks for the solution.
i think i found another solution to this. i read on syslog-ng and i found the following in its configuration file
destination d_fancy_file { file("/var/log/$YEAR/$MONTH/$DAY/$FACILITY.$PRIORITY.log" \
owner(root) group(root) perm(0600) dir_perm(0700) create_dirs(yes)); };
which places the log in a different folder.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.