How to intercept 3rd party library log messages in Gradle?


Is there a way to intercept logging from the 3rd party library used by my gradle build and provide my own behavior for handling those log messages?

For example, I tried adding a StandardOutputListener to my gradle logger, but this one did not get invoked when INFO messages were logged/sent by my 3rd party library’s log4j, although these messages did show up in gradle’s console when I executed build with the “-i” flag. But they were not intercepted by this StandardOutputListener I added below.

                new StandardOutputListener() {
                    void onOutput(CharSequence charSequence)
                        println("Message intercepted: " + charSequence.toString())

As a workaround, I also tried modifying file inside of my 3rd party library .jar file that I import in my gradle project, but this had no effect either.

Thanks, Dmitriy.

I’d really like to be able to do this too. Did you work out a solution?