Disable logging by third party classes in custom Gradle plugin

Hi, I am working on a custom Gradle plugin and am using the Apache HTTP client, which logs messages. I am trying to not have these log messages show up when people use the plugin. The current way I am doing it is quite hacky and depends on internal Gradle classes:

import org.gradle.internal.logging.events.LogEvent;
import org.gradle.internal.logging.events.OutputEventListener;
import org.gradle.internal.logging.slf4j.OutputEventListenerBackedLoggerContext;
...
OutputEventListenerBackedLoggerContext context =
    (OutputEventListenerBackedLoggerContext) LoggerFactory.getILoggerFactory();
OutputEventListener defaultOutputEventListener = context.getOutputEventListener();
context.setOutputEventListener(
    event -> {
      LogEvent logEvent = (LogEvent) event;
      if (!logEvent.getCategory().contains("org.apache")) {
        defaultOutputEventListener.onOutput(event);
      }
    });

I was wondering if there is a better way of going about this?

Just giving this a bump to check if there’s anyone knows of a better way of disabling logging?