How to change timestamp format on rsyslog
Asked Answered
V

1

6

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 ?

Voyageur answered 23/3, 2018 at 12:5 Comment(0)
V
9

The modification is the following:

$template Mytemplate,"%$year%-%$month%-%$day% %timegenerated:12:19:date-rfc3339% %HOSTNAME% %syslogseverity-text:0:3:uppercase% %msg%\n"
Voyageur answered 23/3, 2018 at 12:5 Comment(1)
Thank you for a clear and detailed question, and a specific usable answer!Sideband

© 2022 - 2024 — McMap. All rights reserved.