0

Basically, I want my logs to appear in the format /var/log/2014-03-01/192.168.3.2_SW0002 where 192.168.3.2_SW0002 is a file automatically generated by rsyslog.

$template routerLogFile,"/etc/logs/**2014-03-01**/%fromhost-ip%_%HOSTNAME%"

Currently I have a cron job set up to create a folder with name=current date everyday, except I am not sure how to use rsyslog to specify the intermediate folder before the automatically generated IP address and hostname.

$template routerLogFile,"/etc/logs/%timegenerated:::date-strftime(%Y-%m-%d)%/%fromhost-ip%_%HOSTNAME%"

I previously had this which created a new logfile for each message received. I can't figure out a way to get rsyslog to recognize the date folder.

Any ideas?

user
  • 493
  • 6
  • 13

1 Answers1

0

Alternative solution - I wrote a script which updated the date in the /etc/rsyslog.conf file to the current date at midnight every day, so folders were automatically generated with the current date.

$template routerLogFile,"/var/log/2015/02/05/router/%fromhost-ip%_%HOSTNAME%\n"

i.e. the date field in the rsyslog.conf file was updated.

user
  • 493
  • 6
  • 13