1

How to temporarily disable logging using Zap logger in Go. I need to mute logs for a particular function without removing logger print statements. I need a solution similar to what we do for fmt as below,

temp := os.Stdout
os.Stdout = nil
fmt.Println("Hello")
os.Stdout = temp
fmt.Println("Bye")
Gopi Kumar
  • 53
  • 5
  • basically set up your logger in such a way that you can update the log level at runtime, then in the function that you want to mute, set a log level higher than all other logs. You can also convert an arbitrarily large number, e.g. `zapcore.Level(10000)` – blackgreen Nov 18 '22 at 15:35

0 Answers0