Score:0

rsyslog change timestamp format for specifix filter

vn flag

I wish to change my rsyslog timestamp format to RFC-3339 of specific log file (msg).

I have the following file /etc/rsyslog.d/10-zn.conf with the following content:

:msg, contains, "my_prefix"       /var/log/zn.log

which means that save to /var/log/zn.log all of the lines which contains "my_prefix".

I wish to change the timestamp from RSYSLOG_TraditionalFileFormat which is %b %d %H:%M:%S to RFC-3339 but I can find out how to do it just for the logs which contains my prefix, is there any way to do it?

thank you

Score:0
vn flag

Found the right configuration

if $msg contains '{{my_prefix}}' then { 
        action(type="omfile" file="/var/log/zn.log" template="RSYSLOG_FileFormat")
}

RSYSLOG_FileFormat template already come with RFC3339 timestamp

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.