I have a gradle plugin that uses a library. The library uses archaius, which ends up logging some information using sl4j.
When I execute a task from my plugin, it ends up using this library, which then ends up using archaius. This means I start seeing all of these log messages that come from archaius. Is there any way to turn this off?
Things I have tried:
LIFECYCLE
/ QUIET
.logging.properties
file to the plugin's src/main/resources
with com.netflix.level = QUIET
.Neither of the above worked. Is there a way to disable these log messages?
I figured out how to do it. Unfortunately it depends on internal classes in gradle, but I couldn't figure out any other way:
void apply(Project project) {
OutputEventListenerBackedLoggerContext context = (OutputEventListenerBackedLoggerContext) LoggerFactory.getILoggerFactory();
context.reset()
context.setOutputEventListener(new StfuLogger())
}
class StfuLogger implements OutputEventListener {
@Override
void onOutput(OutputEvent event) {
LogEvent logEvent = (LogEvent) event
if(!logEvent.category.contains("com.netflix")) {
println(logEvent.message)
}
}
}
The idea is to get the logger factory implementation that gradle uses, reset it, and then supply a new output-event listener. Doing it with project.gradle.useLogger(new StfuLogger())
doesn't work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.