logrus/hooks/syslog
Toby c8b0c0e43b
Fixing import for airbrake and adding build constraint to example hook
2016-07-27 13:12:26 +01:00
..
README.md Fixing import for airbrake and adding build constraint to example hook 2016-07-27 13:12:26 +01:00
syslog.go Renaming 'Sirupsen' to 'sirupsen' 2016-07-18 16:36:46 +01:00
syslog_test.go Renaming 'Sirupsen' to 'sirupsen' 2016-07-18 16:36:46 +01:00

README.md

Syslog Hooks for Logrus :walrus:

Usage

import (
  "log/syslog"
  "github.com/sirupsen/logrus"
  logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
)

func main() {
  log       := logrus.New()
  hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")

  if err == nil {
    log.Hooks.Add(hook)
  }
}

If you want to connect to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). Just assign empty string to the first two parameters of NewSyslogHook. It should look like the following.

import (
  "log/syslog"
  "github.com/sirupsen/logrus"
  logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
)

func main() {
  log       := logrus.New()
  hook, err := logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "")

  if err == nil {
    log.Hooks.Add(hook)
  }
}