简体   繁体   English

如何为自定义Gradle插件设置不同的日志级别

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

I'm writing a flyway wrapper plugin for gradle. 我正在为gradle编写一个flyway包装器插件。 Flyway already uses log4j for it's message logging. Flyway已经使用log4j进行消息记录了。

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. 我必须运行gradle flywayStatus --info来查看消息。

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? 有没有一种方法可以更改插件中的log4j设置,以便在使用该插件的项目中无需修改日志级别?

Any idea would really be appreciated. 任何想法将不胜感激。

Thanks, Gerwin 谢谢格温

You can get access to the LoggingManager for the task by calling its getLogging() method. 您可以通过调用任务的getLogging()方法来访问LoggingManager

You can set the logging level on the Manager. 您可以在Manager上设置日志记录级别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM