# renaming a syslog log file in the current date format



## coolatt (Jan 14, 2009)

hi !

plz help with configuring syslog to write to a new  log file(file name format must be YY-MM-DD) everyday

thx.


----------



## SirDice (Jan 14, 2009)

AFAIK neither syslog nor newsyslog is able to do that. You will need to create a script that does this.


----------



## coolatt (Jan 14, 2009)

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 (Jan 14, 2009)

but can *syslog-ng* do that ?


----------



## DutchDaemon (Jan 14, 2009)

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 (Jan 14, 2009)

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.


----------

