sh0umik / elogrus

Logrus Hook for ElasticSearch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ElasticSearch Hook for Logrus :walrus:

Usage

package main

import (
	"github.com/Sirupsen/logrus"
	"github.com/sohlich/elogrus"
	"gopkg.in/olivere/elastic.v3"
)


func main() {
	log := logrus.New()
	client, err := elastic.NewClient(elastic.SetURL("http://localhost:9200"))
	if err != nil {
		log.Panic(err)
	}	
	hook := NewElasticHook(client, "localhost", logrus.DebugLevel, "mylog")
	log.Hooks.Add(hook)

	log.WithFields(logrus.Fields{
		"name": "joe",
		"age":  42,
	}).Error("Hello world!")
}

About

Logrus Hook for ElasticSearch


Languages

Language:Go 100.0%