Search code examples
datetimetimestamprsyslogformatdatetime

How to change timestamp format on rsyslog


I want to change the default timestamp format on rsyslog. Currently I am running on RHEL7.2. Syslog version 7.4.7. Now the default format is the following:

Mar 23 09:35:30 localhost DEB  [9125:<console>.<module>:2] debug info

Inside rsyslog.conf I have define the following template:

$template Mytemplate,"%timegenerated% %HOSTNAME% %syslogseverity-text:0:3:uppercase% %msg%\n"

How can I change the format to this YYYY-MM-dd H:i:s ?


Solution

  • The modification is the following:

    $template Mytemplate,"%$year%-%$month%-%$day% %timegenerated:12:19:date-rfc3339% %HOSTNAME% %syslogseverity-text:0:3:uppercase% %msg%\n"