There's some interaction between setup of `log` and `slog` that is not revertible.
Before `slog.SetDefault`, it's sort of the case that the `log` package's default resource is the destination for all global/default/standard logging (from `slog` or `log`). The mechanism is a little aggressive, even, in the details - there is a slog handler that outputs via a resource managed by the log function. The function is made visible via a pointer held in a `log/internal` package log and slog both import. After `slog.SetDefault`, the opposite configuration occurs in the sense that `log` sends its output into `slog`. I don't believe this flip is revertible. If you must have `log` formatting, I think the thing that might be possible to implement a `slog` handler with formatting that precisely matched the `log`/pre-`SetDefault` arrangement. Dunno if that implementation exists already somewhere. An easier bar would be to set a `slog.NewTextHandler` as default. Hope this helps. On Thursday, April 17, 2025 at 8:04:46 AM UTC-7 Chris Burkert wrote: > Dear all, > > I thought I can temporarily replace the slog default logger and eventually > revert to the previous one. But this seems not to be possible: > https://play.golang.com/p/OQbgGm_DRLY > > Can someone explain, what is happening and how I can achieve my goal? > > Chris > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/122b6044-1869-4d3c-9ebc-fd27f5ac9672n%40googlegroups.com.