![](https://camo.githubusercontent.com/d7777fa9b9453e04322447654ad034184f9010dbb605cfb98760b5bbed2c4e0b/68747470733a2f2f7472617669732d63692e6f72672f736f686c6963682f656c6f677275732e7376673f6272616e63683d6d6173746572)
- elastic 6.x support (currently in master)
- v2.1 - Added support for async hook
go get gopkg.in/sohlich/elogrus.v3
package main
import (
"github.com/sirupsen/logrus.v3"
"gopkg.in/sohlich/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")
...