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?