Catalogue
Changing the Logging Level with Go logrus

Changing the Logging Level with Go logrus

🌐 日本語で読む

Overview

Go’s sirupsen/logrus is so handy that I’m writing this down as a memo.

When building tools in Go, there are times when I want to quickly change the level for debugging, and this is what I use for that.

It’s easier to understand by actually running it.

Go Playground

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package main

import (
log "github.com/sirupsen/logrus"
)

func main() {
log.SetLevel(log.FatalLevel)

log.Trace("1")
log.Debug("2")
log.Info("3")
log.Warn("4")
log.Error("5")
log.Fatal("6")
log.Panic("7")
}

That’s all.
I hope this is helpful.

Changing the Logging Level with Go logrus

https://kenzo0107.github.io/en/2020/11/27/go-logging-level/

Author

Kenzo Tanaka

Posted on

2020-11-27

Licensed under