Logy|Docs

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.

main.go
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:

  • Level decides the minimum accepted log level.
  • Handlers selects the destinations that receive records.
  • Console, File, and Syslog configure each built-in destination.
  • Json changes 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.