Richtige rsyslog-Konfiguration

Richtige rsyslog-Konfiguration

Ich habe Debian 8 (Jessie) und muss Nachrichten ins Protokoll schreiben. Angenommen, ich habe ein Programm, das an das Syslog sendet:

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

Teil von /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 der Protokolldatei sehe ich:

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

Alle Nachrichten sind Teile einer großen Zeile. Was muss ich in der Konfiguration/im Programm ändern, um mehrere Zeilen statt einer zu haben?

verwandte Informationen