Index: syslogd.8 =================================================================== --- syslogd.8 +++ syslogd.8 @@ -28,7 +28,7 @@ .\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd July 2, 2018 +.Dd June 20, 2020 .Dt SYSLOGD 8 .Os .Sh NAME @@ -45,6 +45,7 @@ .Op Fl O Ar format .Op Fl P Ar pid_file .Op Fl p Ar log_socket +.Op Fl r Ar format .Op Fl S Ar logpriv_socket .Sh DESCRIPTION The @@ -260,8 +261,12 @@ .Fl s . .It Fl n Disable DNS query for every request. -.It Fl O Ar format -Select the output format of generated log messages. +.It Fl O Ar format , Fl r Ar format +Select the output format of generated log messages +.Pq Fl O , +or just the format of log messages sent over the network to a remote +log server +.Pq Fl r . The values .Ar bsd and Index: syslogd.c =================================================================== --- syslogd.c +++ syslogd.c @@ -406,6 +406,7 @@ static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */ static struct pidfh *pfh; static int sigpipe[2]; /* Pipe to catch a signal during select(). */ +static bool RFC3164NetworkFormat = true; /* Send legacy format over the wire. */ static bool RFC3164OutputFormat = true; /* Use legacy format by default. */ static volatile sig_atomic_t MarkSet, WantDie, WantInitialize, WantReapchild; @@ -553,7 +554,7 @@ if (madvise(NULL, 0, MADV_PROTECT) != 0) dprintf("madvise() failed: %s\n", strerror(errno)); - while ((ch = getopt(argc, argv, "468Aa:b:cCdf:FHkl:m:nNoO:p:P:sS:Tuv")) + while ((ch = getopt(argc, argv, "468Aa:b:cCdf:FHkl:m:nNoO:p:P:r:sS:Tuv")) != -1) switch (ch) { #ifdef INET @@ -692,6 +693,16 @@ case 'P': /* path for alt. PID */ PidFile = optarg; break; + case 'r': + if (strcmp(optarg, "bsd") == 0 || + strcmp(optarg, "rfc3164") == 0) + RFC3164NetworkFormat = true; + else if (strcmp(optarg, "syslog") == 0 || + strcmp(optarg, "rfc5424") == 0) + RFC3164NetworkFormat = false; + else + usage(); + break; case 's': /* no network mode */ SecureMode++; break; @@ -950,7 +961,7 @@ " [-b bind_address] [-f config_file]\n" " [-l [mode:]path] [-m mark_interval]\n" " [-O format] [-P pid_file] [-p log_socket]\n" - " [-S logpriv_socket]\n"); + " [-r format] [-S logpriv_socket]\n"); exit(1); } @@ -2143,6 +2154,7 @@ const char *procid, const char *msgid __unused, const char *structured_data __unused, const char *msg, int flags) { + bool RFC3164; dprintf("Logging to %s", TypeNames[f->f_type]); f->f_time = now; @@ -2152,7 +2164,10 @@ return; } - if (RFC3164OutputFormat) + RFC3164 = (f->f_type == F_FORW) ? RFC3164NetworkFormat : + RFC3164OutputFormat; + + if (RFC3164) fprintlog_rfc3164(f, hostname, app_name, procid, msg, flags); else fprintlog_rfc5424(f, hostname, app_name, procid, msgid,