Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a different log level for a Custom Gradle Plugin

I'm writing a flyway wrapper plugin for gradle. Flyway already uses log4j for it's message logging.

On the info level all the output is relevant to the user.

When I add the custom plugin to new project and run one of its tasks than nothing is displayed in the output. I have to run gradle flywayStatus --info to see the messages.

Is there a way to change the log4j settings in the plugin so that the log level does not need to be modified in the projects that use the plugin?

Any idea would really be appreciated.

Thanks, Gerwin

like image 327
Gerwin Brunner Avatar asked Oct 12 '12 13:10

Gerwin Brunner


People also ask

How do I create a Gradle build log?

View -> Tool Windows -> Build. There is small "ab" button on the left panel. All gradle logs for current build are there.

Which are the two types of plugins in Gradle?

There are two general types of plugins in Gradle, binary plugins and script plugins.

What is Buildscript in Gradle?

buildscript: This block is used to configure the repositories and dependencies for Gradle. Note: Don't include dependencies here. ( those will be included in the module-level build.gradle) dependencies: This block in buildscript is used to configure dependencies that the Gradle needs to build during the project. Java.

What is projectDir in Gradle?

projectDir File The directory containing the build script. The value is read-only. buildDir File The directory with the build name in the directory, containing the build script. rootDir File The directory of the project at the root of a project structure.


1 Answers

You can get access to the LoggingManager for the task by calling its getLogging() method.

You can set the logging level on the Manager.

like image 196
Dylan Bijnagte Avatar answered Oct 26 '22 15:10

Dylan Bijnagte