Logy|Docs

File handler

Write records to a local file

Use the file handler when the process should maintain a local log file in addition to, or instead of, console output.

main.go
err := logy.LoadConfig(&logy.Config{
	Handlers: logy.Handlers{"console", "file"},
	File: &logy.FileConfig{
		Enabled: true,
		Path:    "logs/application.log",
		Level:   logy.LevelInfo,
	},
})
if err != nil {
	panic(err)
}

Path selects where records are written.

Level controls which records reach the file destination.

Keep file output disabled in environments where stdout is already collected by the platform.