Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.
/ elogrus Public archive
forked from go-extras/elogrus

Logrus Hook for Elasticsearch Using the Official Go Client

License

Notifications You must be signed in to change notification settings

bgsrb/elogrus

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elasticsearch Hook for Logrus :walrus:

Intro

This is a hard fork of https://github.com/sohlich/elogrus. The original library used https://github.com/olivere/elastic, which is a non-official Elasticsearch go client. This fork uses the official client library.

Releases

This fork is designed to use the official Go client for Elasticsearch

Notice that the master branch always refers to the latest version of Elastic. If you want to use stable versions of elogus, you should use the packages released via gopkg.in.

Here's the version matrix:

Elasticsearch version Elastic Go Client version Package URL Remarks
6.x 6.0 gopkg.in/go-extras/elogrus.v6 Actively maintained.

For Elasticsearch 6.x

# We name v6 to align with elastic v6
go get github.com/elastic/go-elasticsearch/v6
go get gopkg.in/go-extras/elogrus.v6

Changelog

Usage

package main

import (
	"github.com/elastic/go-elasticsearch/v6"
	"github.com/sirupsen/logrus"
	"gopkg.in/go-extras/elogrus.v6"
)

func main() {
	log := logrus.New()
	client, err := elasticsearch.NewClient(elasticsearch.Config{
		Addresses: []string{"http://127.0.0.1:7777"},
	})
	if err != nil {
		log.Panic(err)
	}
	hook, err := elogrus.NewAsyncElasticHook(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

	...
	elogrus.NewAsyncElasticHook(client, "localhost", logrus.DebugLevel, "mylog")
	...

About

Logrus Hook for Elasticsearch Using the Official Go Client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%