Skip to content

Instantly share code, notes, and snippets.

@david-bakin-sl
Created March 21, 2023 16:18
Show Gist options
  • Save david-bakin-sl/7f458ac55a890be99c1763b60f14a603 to your computer and use it in GitHub Desktop.
Save david-bakin-sl/7f458ac55a890be99c1763b60f14a603 to your computer and use it in GitHub Desktop.
Remove all log4j2 appenders
private void removeLogging() {
final var ctx = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false);
final var configuration = (AbstractConfiguration) ctx.getConfiguration();
final var allAppenders = configuration.getAppenders();
for (final var appenderName : allAppenders.keySet()) {
configuration.removeAppender(appenderName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment