-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Description
The default provider.New sets up the structured/text slog.Logger for use out of the box. These logs are printed to stderr and as per the host otel documentation these aren't exported to otel. The otel logger which is setup in the provider also doesn't forward them. I propose that if remote logs are enabled then the p.Logger should automatically forward them.
The library github.com/samber/slog-multi allows you to fanout to multiple slog.Handler. The code would look something like the following:
if hostData.OtelConfig.LogsEnabled() {
// existing loggerProvider setup...
logger = slog.New(slogmulti.Fanout(
logger.Handler(),
otelslog.NewHandler(
"provider",
otelslog.WithLoggerProvider(loggerProvider),
),
))
}
Would anyone have any objections to this or is it preferred for logs to be exported to otel manually?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels