logrus middleware

An adapter (middleware) to make the Golang Echo web framework logging work with logrus, an excellent logging solution.

Improves upon sandalwing/echo-logrusmiddleware by:

  1. Using the correct dependencies
  2. Including the request_id prop in the log output in order to support echo's request ID middleware.
  3. Supporting logging the full request/response body


$ go get


package main

import (

func main() {
	e := echo.New()

	e.Logger = logrusmiddleware.Logger{Logger: logrus.StandardLogger()}

	// to set up request logging using the default parameters (basic fields logged, but no request/response bodies)

	// to define your own config
	config := &logrusmiddleware.Config{
		IncludeRequestBodies:  true,
		IncludeResponseBodies: true,

	// do the rest of your echo setup, routes, listen on server, etc..
Expand ▾ Collapse ▴




This section is empty.


This section is empty.


func Hook

func Hook() echo.MiddlewareFunc

func HookWithConfig

func HookWithConfig(config Config) echo.MiddlewareFunc


type Config

type Config struct {
	IncludeRequestBodies  bool
	IncludeResponseBodies bool

type Logger

type Logger struct {

func (Logger) Debugj

func (l Logger) Debugj(j log.JSON)

func (Logger) Errorj

func (l Logger) Errorj(j log.JSON)

func (Logger) Fatalj

func (l Logger) Fatalj(j log.JSON)

func (Logger) Infoj

func (l Logger) Infoj(j log.JSON)

func (Logger) Level

func (l Logger) Level() log.Lvl

func (Logger) Output

func (l Logger) Output() io.Writer

func (Logger) Panicj

func (l Logger) Panicj(j log.JSON)

func (Logger) Prefix

func (l Logger) Prefix() string

func (Logger) Printj

func (l Logger) Printj(j log.JSON)

func (Logger) SetHeader

func (l Logger) SetHeader(_ string)

SetHeader is a stub to satisfy the Logger interface It's controlled by logrus

func (Logger) SetLevel

func (l Logger) SetLevel(lvl log.Lvl)

func (Logger) SetOutput

func (l Logger) SetOutput(w io.Writer)

func (Logger) SetPrefix

func (l Logger) SetPrefix(_ string)

func (Logger) Warnj

func (l Logger) Warnj(j log.JSON)

Source Files