You can programmatically add or remove an appender. In your case let's remove Console
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
config.getRootLogger().removeAppender("CONSOLE");
ctx.updateLoggers();
There is a LifeCycle interface with methods stop
and start
, but it looks like you can not restart an appender after it was stopped.