0

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?

Mureinik
  • 119
  • 6
Boris
  • 1
  • 1

0 Answers0