Thanks Andrew, I see. As you mentioned I get a consistent behaviour if I define my own logger in the first place. https://play.golang.com/p/PriUZnVKJOn Chris
Am Fr., 18. Apr. 2025 um 01:27 Uhr schrieb Andrew Harris < harris.and...@gmail.com>: > Sorry for spam, quick clarification: where I said "there is a slog handler > that outputs via a resource managed by the log function" that's a bit > jumbled, I intended to say "resource managed by the log package". > On Thursday, April 17, 2025 at 4:21:17 PM UTC-7 Andrew Harris wrote: > >> 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/a20ceaa1-1280-425f-b1f9-72552d3497a7n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/a20ceaa1-1280-425f-b1f9-72552d3497a7n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CALWqRZo88Nms_a%3DucrTVrjWYgLUDpe6C08MOv5fSqYwdC8_jNQ%40mail.gmail.com.