Log output from gradle tasks with log4j2

I am trying to use log4j2 configuration to log output from gradle tasks.
for example, I want to use appenders from log4j2 configuration to handle below logs from “gradle build” command.

is it possible with gradle level? or even in ant configurations?

> Task :test FAILED

TestserverApplicationTests > contextLoads() FAILED
    org.opentest4j.AssertionFailedError at TestserverApplicationTests.java:21

1 test completed, 1 failed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///Users/jaekukkim/dev/testserver/build/reports/tests/test/index.html

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

7 actionable tasks: 1 executed, 6 up-to-date

No, Gradle is not using log4j for its logging, so you cannot use log4j configuration to configure the logging.
The Gradle logging unfortunately is very inflexible with logging, you can basically just use --quiet, --info and --debug to configure it, or configure an own logging handler where you then have to handle all logging yourself.