Using org.slf4j.MDC with Netty channels?
Asked Answered
D

1

15

What I want to do is in essence what How to use MDC with thread pools? is asking, but with Netty.

I want MDC information associated per Channel. What options are there for Netty? If I need to reset MDC manually, what methods can I hook up to do this from one place?

Diplodocus answered 23/2, 2015 at 7:12 Comment(0)
F
0

I believe I would implement a custom ChannelHandler and register it on the ChannelPipeline (probably as the very first handler).

See the section "state management" on the linked JavaDoc page.

You can attach information to the ChannelHandlerContext's attributes which the handler can then set on the MDC.

For best results, create a corresponding handler at the end of the pipeline to clean up the MDC.

Ferroconcrete answered 26/4, 2024 at 17:24 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.