How do I capture logger.warn message raised in a plugin

I use a plugin - which I can’t modify - that prints a warning message and a stack trace. I’m not using the part of the plugin that this message concerns so I don’t want the stack trace to appear in my build log.
I know that the message is written using the format

    try {
        [...]
    } catch(e) {
        project.logger.warn('A warning message', e)
    }

Is there any way I can capture this warning message in my script when I apply the plugin?

I’ve tried setting logging.captureStandardOutput and logging.captureStandardError to LogLevel.INFO but that doesn’t help. It seems like that setting only affect the current environment, i.e. when a task is executed (and probably a plugin is applied) the log level is reset to its default.

I’ve spent about a day searching all over the place to find a solution but I haven’t succeeded. Maybe because I’m pretty new to Gradle and don’t understand all I read.
Any suggestion that would put me in the right direction is really appreciated!