Re: downsides/overhead of stashing & restoring (probably empty) ThreadContextMap ?

2021-11-08 Thread Ralph Goers
> On Nov 8, 2021, at 3:04 PM, Chris Hostetter wrote: > > > And if the ThreadContext is _not_ empty? ... is there anything about how > it's implemented that would make the initial map copy (and later > `putAll(...)` call) more "epensive" from a performance standpoint then an > off the shelf

Re: downsides/overhead of stashing & restoring (probably empty) ThreadContextMap ?

2021-11-08 Thread Matt Sicker
In a servlet environment, the overhead of MDC logging is minuscule compared to the servlet itself. Allocating that in a filter is about the best you can do here unless you don’t need it for all requests. In a reactive streams style web app, though, that might be a little heavier due to copying c

Re: downsides/overhead of stashing & restoring (probably empty) ThreadContextMap ?

2021-11-08 Thread Chris Hostetter
: Personally, I wouldn’t bother. I have a standard practice of populating : the ThreadContextMap from HTTP headers in a ServletFilter and then : clearing the ThreadContext on the way out. See : https://github.com/apache/logging-log4j-audit/blob/master/log4j-audit/log4j-audit-api/src/main/java

Re: downsides/overhead of stashing & restoring (probably empty) ThreadContextMap ?

2021-11-08 Thread Ralph Goers
Personally, I wouldn’t bother. I have a standard practice of populating the ThreadContextMap from HTTP headers in a ServletFilter and then clearing the ThreadContext on the way out. See https://github.com/apache/logging-log4j-audit/blob/master/log4j-audit/log4j-audit-api/src/main/java/org/apache

downsides/overhead of stashing & restoring (probably empty) ThreadContextMap ?

2021-11-08 Thread Chris Hostetter
TL;DR: Are there any serious performance concerns to be aware of with using something like... doFilter(ServletRequest req, ServletResponse rsp, FilterChain c) { final Map ctx = ThreadContext.getContext(); try { c.doFilter(req,rsp); } finally { ThreadContext.clearMap() if (

Re: Fwd: Temporarily store/restore the current configuration

2021-11-08 Thread Chris Hostetter
: var ctx = (LoggerContext) LogManager.getContext(false); : var current = ctx.getConfiguration(); : try { : ctx.setConfiguration(myQuietConfiguration); : otherCode(); : } finally { : ctx.setConfiguration(current); : } : : But it doesn't. Neither with reconfigure nor with setConfiguration.