Configuration
Configure levels, handlers, formats, and output behavior
Logy configuration controls what records are accepted, where they are written, and how they are formatted.
Use programmatic configuration when logging is part of application startup. Use YAML when the same binary should behave differently per environment.
err := logy.LoadConfig(&logy.Config{
Level: logy.LevelInfo,
Handlers: logy.Handlers{"console"},
Console: &logy.ConsoleConfig{
Enabled: true,
Color: true,
Format: "%d{2006-01-02 15:04:05.000} %p %c : %s%e%n",
},
})
if err != nil {
panic(err)
}The important parts are:
Leveldecides the minimum accepted log level.Handlersselects the destinations that receive records.Console,File, andSyslogconfigure each built-in destination.Jsonchanges a handler from readable pattern output to structured records.- Package configuration can override behavior for a package or sub-package.
Continue with Programmatic configuration or YAML configuration.
