Score:0

Proper rsyslog configuration

ye flag

I have Debian 8 (Jessie) and need to write messages to log. Suppose, I have a program which sends to syslog:

#include <syslog.h>
int main()
{
   openlog("progname", LOG_CONS, LOG_USER);
   const char* msg = "{\"dt\":\"1670932865\",\"msg\":\"OK\"}";
   syslog(LOG_INFO, "%s", msg);
   closelog();
}

Part of /etc/rsyslog.conf:

template(name="outfmt" type="list") {
    property(name="msg")
}
if $programname startswith "progname" then {
    action(type="omfile" file="/path/to/file.log" template="outfmt")
    & stop
}

In log file I see:

{"dt":"1670932865","msg":"OK"} {"dt":"1670932865","msg":"OK"}

All messages are parts of one big line. What must I change in the configuration/program to have multiple lines instead of one?

jp flag
https://www.rsyslog.com/doc/v8-stable/configuration/templates.html
Boris avatar
ye flag
@AlexD, thanks, it helps.
I sit in a Tesla and translated this thread with Ai:

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.