2017-10-10 08:13:14 +00:00
# Syslog Hooks for Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/>
## Usage
```go
import (
"log/syslog"
2017-10-10 08:14:44 +00:00
"github.com/sirupsen/logrus"
lSyslog "github.com/sirupsen/logrus/hooks/syslog"
2017-10-10 08:13:14 +00:00
)
func main() {
log := logrus.New()
2017-10-10 08:14:44 +00:00
hook, err := lSyslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
2017-10-10 08:13:14 +00:00
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.
```go
import (
"log/syslog"
2017-10-10 08:14:44 +00:00
"github.com/sirupsen/logrus"
lSyslog "github.com/sirupsen/logrus/hooks/syslog"
2017-10-10 08:13:14 +00:00
)
func main() {
log := logrus.New()
2017-10-10 08:14:44 +00:00
hook, err := lSyslog.NewSyslogHook("", "", syslog.LOG_INFO, "")
2017-10-10 08:13:14 +00:00
if err == nil {
log.Hooks.Add(hook)
}
}
2017-10-10 08:14:44 +00:00
```