vgough commented on issue #37143:
URL: https://github.com/apache/beam/issues/37143#issuecomment-4085615277

   The way I dealt with this issue is to have a local logging setup library. 
This configures slog handler defaults, sets up common attribute extraction, and 
configures `log` to output to slog for one common output.
   
   It also checks if the remote logging hook is enabled 
(`hooks.IsEnabled(harness.DefaultRemoteLoggingHook)`), and if so then enables a 
hook to configure beam logging on the worker. The custom hook extracts out the 
configured log level and creates an slog handler which writes to beam's 
`log.Output`.  It only works if using slog's *Context methods, since that makes 
the context available through the handlers to the beam logger.
   
   It was quite painful to get this all working smoothly.
   
   Related, there was a plan to migrate to `slog`, since that would ideally 
replace custom log libraries in Go: 
https://docs.google.com/document/d/131EZH5I6GbzjF2OsQbvcZj-ZgU_XMRX9KnoJG1k-Mqc/edit?usp=sharing
   > The Go SDK uses a custom 
[log](https://github.com/apache/beam/blob/c0b6db91ccc8e9b2a780894f2a51f13021502657/sdks/go/pkg/beam/log/log.go)
 module. The default handler 
[creates](https://github.com/apache/beam/blob/c0b6db91ccc8e9b2a780894f2a51f13021502657/sdks/go/pkg/beam/core/runtime/harness/logging.go#L58)
 LogEntries and sends them to the FnHarness. A context.Context object is used 
throughout the code, which could be used for MDC. There's a 
[plan](https://docs.google.com/document/d/131EZH5I6GbzjF2OsQbvcZj-ZgU_XMRX9KnoJG1k-Mqc/edit?disco=AAAArD73nH8)
 to migrate to 
[slog](https://go.googlesource.com/proposal/+/master/design/56345-structured-logging.md)
 once it's in an official Go release, which supports Structured logging.
   
   Not clear what happened to that.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to