Logy|Docs

Programmatic configuration

Configure Logy from Go application startup code

Use logy.LoadConfig when the application builds logging configuration during startup.

main.go
func init() {
	err := logy.LoadConfig(&logy.Config{
		Level:    logy.LevelInfo,
		Handlers: logy.Handlers{"console"},
		Console: &logy.ConsoleConfig{
			Enabled: true,
			Color:   true,
		},
	})
	if err != nil {
		panic(err)
	}
}

LoadConfig applies the configuration to the logging runtime. Call it before the application starts writing logs so every logger observes the same settings.

Programmatic configuration is useful when settings come from another config system, environment variables, command flags, or application defaults.