Integration slog with uber-go/fx
.
Note: slog required Go 1.19+
app := fx.New(
fx.Provide(func() *slog.Logger {
return slog.New(slog.NewJSONHandler(os.Stdout))
}),
fx.WithLogger(func(logger *slog.Logger) fxevent.Logger {
return fxslog.New(logger)
}),
)
defer app.Stop(context.TODO())
app.Start(context.TODO())