- elastic 7.x support (currently in master)
- elastic 6.x support (in v3)
- v2.1 - Added support for async hook
go get github.com/meateam/elogrus.v4
package main
import (
"github.com/sirupsen/logrus"
"github.com/meateam/elogrus"
"gopkg.in/olivere/elastic"
)
func main() {
log := logrus.New()
client, err := elastic.NewClient(elastic.SetURL("http://localhost:9200"))
if err != nil {
log.Panic(err)
}
hook, err := elogrus.NewElasticHook(client, "localhost", logrus.DebugLevel, "mylog")
if err != nil {
log.Panic(err)
}
log.Hooks.Add(hook)
log.WithFields(logrus.Fields{
"name": "joe",
"age": 42,
}).Error("Hello world!")
}
...
elogrus.NewAsyncElasticHook(client, "localhost", logrus.DebugLevel, "mylog")
...