0

On a Debian 9 (stretch) system, 4.14 kernel I have some applications written in Go that make extensive use of logging. I'm finding that these log messages are being triplicated.

With the following code, all log messages are written to /var/log/messages , /var/log/kern.log and /var/log/syslog

I think it has something to do with journald and syslog (or rsyslog) doing double duty but I'm not sure.

If it helps, this is a stock Beaglebone Black running the Debian distro.

How do I stop these messages from being written to kern.log and syslog and just write them to messages?

package main

import (
    "log"
    "log/syslog"
)

func main() {
    logwriter,e:= syslog.New(syslog.LOG_NOTICE,"testprog")
    if e == nil {
        log.SetOutput(logwriter)
    }
    log.Println("Hello Friend")
}
kostix
  • 51,517
  • 14
  • 93
  • 176

1 Answers1

0

Found my problem. So for anyone having the same issue.

edit /etc/systemd/journald.conf

Remove the comment for the line "ForwardToSyslog=yes" and change to no. Restart journald

EDIT

Just in case anyone finds this message with the same problem, there is an extra step I needed. I had some running bins that were using Go's log functions. They had to be restarted for their logs to show properly in journald.