Hello,

I've been looking for a solution to a problem and I can't figure out
the solution. I have test code that recursively calls certain routines
which emit quite a bit of logging to the console. I'd like to
temporarily switch the configuration to one that is less chatty, but
restore the previous configuration afterward.

I looked at the LoggerContext and its reconfigure(Configuration) and
setConfiguration(Configuration) methods, thinking something like this
would work:

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.
The root logger's appender is never reattached properly.

I wonder what I'm missing here. I've tried several other avenues but I
will spare you the code as none of them worked properly. Any help
would be greatly appreciated.

Dawid

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to