This repository has been archived on 2025-10-08. You can view files and clone it, but cannot push or open issues or pull requests.
miniauthold/vendor/github.com/seatgeek/logrus-gelf-formatter
kekskurse 19dab2268e
Some checks failed
ci/woodpecker/push/test Pipeline failed
ci/woodpecker/push/playwright unknown status
ci/woodpecker/push/deplyoment unknown status
chore: login methode return user
2025-05-25 20:41:22 +02:00
..
.gitignore chore: login methode return user 2025-05-25 20:41:22 +02:00
gelf_log_formatter.go chore: login methode return user 2025-05-25 20:41:22 +02:00
gelf_log_formatter_with_timestamp.go chore: login methode return user 2025-05-25 20:41:22 +02:00
LICENSE chore: login methode return user 2025-05-25 20:41:22 +02:00
log_levels.go chore: login methode return user 2025-05-25 20:41:22 +02:00
README.md chore: login methode return user 2025-05-25 20:41:22 +02:00

Logrus GELF Log Formatter

Logrus Only a formatter, outputs the log message in the GELF JSON format as decribed by Graylog 2.

If you are looking for a GELF hook capable of sending directly to graylog, please use this: https://github.com/gemnasium/logrus-graylog-hook

The reason for using just a formatter is that you can write files or directly to stdout in the expected format and then separately ship the lines to graylog, without stealing CPU time from your go app.

Installation

To install formatter, use go get:

$ go get github.com/seatgeek/logrus-gelf-formatter

Usage

Here is how it should be used:

package main

import (
	"github.com/sirupsen/logrus"
	gelf "github.com/seatgeek/logrus-gelf-formatter"
)

var log = logrus.New()

func init() {
	log.Formatter = new(gelf.GelfFormatter)
	log.Level = logrus.DebugLevel
}

func main() {
	log.WithFields(logrus.Fields{
		"prefix": "main",
		"animal": "walrus",
		"number": 8,
	}).Debug("Started observing beach")

	log.WithFields(logrus.Fields{
		"prefix":      "sensor",
		"temperature": -4,
	}).Info("Temperature changes")
}