...
1# Syslog Hooks for Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/>
2
3## Usage
4
5```go
6import (
7 "log/syslog"
8 "github.com/sirupsen/logrus"
9 lSyslog "github.com/sirupsen/logrus/hooks/syslog"
10)
11
12func main() {
13 log := logrus.New()
14 hook, err := lSyslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
15
16 if err == nil {
17 log.Hooks.Add(hook)
18 }
19}
20```
21
22If 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.
23
24```go
25import (
26 "log/syslog"
27 "github.com/sirupsen/logrus"
28 lSyslog "github.com/sirupsen/logrus/hooks/syslog"
29)
30
31func main() {
32 log := logrus.New()
33 hook, err := lSyslog.NewSyslogHook("", "", syslog.LOG_INFO, "")
34
35 if err == nil {
36 log.Hooks.Add(hook)
37 }
38}
39```
View as plain text