2014-07-19 02:45:49 +04: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"
"github.com/Sirupsen/logrus"
2014-12-05 13:00:48 +03:00
logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog"
2014-07-19 02:45:49 +04:00
)
func main() {
log := logrus.New()
2014-07-19 02:47:34 +04:00
hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
2014-07-19 02:45:49 +04:00
if err == nil {
log.Hooks.Add(hook)
}
}
2014-12-05 13:00:48 +03:00
```
2015-09-09 16:55:50 +03:00
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"
"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)
}
}
```