-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Following the docs at https://github.com/sirupsen/logrus/#hooks I'm trying to use an external syslog server to send only WARNING (and above) logs there, while sending debug to local logs. Unfortunately it doesn't seem to work. The external syslog server receives whatever I setup with log.SetLevel()
instead of the priority argument passed to logrus_syslog.NewSyslogHook
.
Am I doing anything wrong here? Maybe I misinterpreted the docs?
package main
import (
log "github.com/sirupsen/logrus"
logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
)
func main() {
log.SetLevel(log.DebugLevel)
hook, err := logrus_syslog.NewSyslogHook("tcp", "localhost:5140", syslog.LOG_WARNING, "test")
if err != nil {
panic(err)
}
log.AddHook(hook)
// These 2 should go both to local and remote logs
log.Warn("ciao with warn")
log.Error("ciao with error")
// These should only go to local logs and not to external syslog,
// but instead they're shown there too :(
log.Debug("ciao with debug")
log.Info("ciao with info")
}
gfanto