How do I set log levels using zerolog in Go?

log levels, zerolog, Go logging, Go programming, structured logging
Learn how to set log levels in Go using the Zerolog library, a fast and simple structured logging package.
package main import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" "os" ) func main() { // Set the log level to debug zerolog.SetGlobalLevel(zerolog.DebugLevel) // Create a logger log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout}) // Log examples at different levels log.Debug().Msg("This is a debug message") log.Info().Msg("This is an info message") log.Warn().Msg("This is a warning message") log.Error().Msg("This is an error message") log.Fatal().Msg("This is a fatal message") }

log levels zerolog Go logging Go programming structured logging