https://github.com/meateam/elogrus
Logrus Hook for ElasticSearch
https://github.com/meateam/elogrus
elasticsearch golang golang-package logging logrus-hook
Last synced: 6 months ago
JSON representation
Logrus Hook for ElasticSearch
- Host: GitHub
- URL: https://github.com/meateam/elogrus
- Owner: meateam
- License: mit
- Fork: true (sohlich/elogrus)
- Created: 2019-05-19T12:58:08.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-20T11:26:22.000Z (about 7 years ago)
- Last Synced: 2024-11-16T12:49:18.326Z (over 1 year ago)
- Topics: elasticsearch, golang, golang-package, logging, logrus-hook
- Language: Go
- Homepage:
- Size: 49.8 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# ElasticSearch Hook for [Logrus](https://github.com/Sirupsen/logrus)

Elasticsearch version | Elastic version | Package URL
----------------------|------------------|------------
7.x | 7.0 | [`github.com/meateam/elogrus.v4`](http://github.com/meateam/elogrus.v4)
6.x | 6.0 | [`github.com/meateam/elogrus.v3`](http://github.com/meateam/elogrus.v3)
5.x | 5.0 | [`github.com/meateam/elogrus.v2`](http://github.com/meateam/elogrus.v2)
2.x | 3.0 | [`github.com/meateam/elogrus.v1`](http://github.com/meateam/elogrus.v1)
## Changelog
- elastic 7.x support (currently in master)
- elastic 6.x support (in v3)
- v2.1 - Added support for async hook
## Import
```
go get github.com/meateam/elogrus.v4
```
## Usage
```go
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!")
}
```
### Asynchronous hook
```go
...
elogrus.NewAsyncElasticHook(client, "localhost", logrus.DebugLevel, "mylog")
...
```