问题描述
我从 gradle 脚本中调用 ant.signjar.我怎样才能捕获它的输出?我既没有轻松管理将输出从 INFO 提升到另一个级别,也没有将输出拦截或包装到错误警告到 WARN 级别.目前,signjar 回应说证书即将过期,但这并没有在 WARN 级别显示,这不太好.
I call ant.signjar from a gradle script.How can I capture its output?I did neither get it managed easily to elevate the output from INFO to another level, nor to intercept or wrap the output to error warnings out to WARN level.Currently the signjar echoes out that the certificate will expire soon, but this is not shown on WARN level which is not so nice.
推荐答案
我假设 Ant 任务正在使用 Ant 的日志记录框架,而不仅仅是打印到标准输出.在这种情况下,您是否尝试过以下操作?
I assume the Ant task is using Ant's logging framework, and not just printing to standard out. In that case, have you tried the following?
task taskThatCallsAntTask {
logging.level = LogLevel.INFO
}
以这种方式配置时,无论在调用 Gradle 时设置了哪个日志级别,日志级别都会在任务执行时更改为 INFO(并在之后恢复).请注意,您不能提升 Ant 日志事件的日志级别;这取决于 Ant 任务在哪个级别记录.
When configured in this way, the log level will be changed to INFO while the task is executing (and reverted back afterwards), no matter which log level is set when invoking Gradle. Note that you can't elevate the log level of an Ant log event; it's up to the Ant task at which level it logs.
这篇关于从 Gradle 调用 Ant 任务时如何拦截或提升日志消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!