useLogger no longer replaces the standard Gradle task logging


(Andrew Richardson) #1

I have a project that invokes “useLogger” to replace Gradle’s standard task logging with our own (ie we have a logger that implements TaskExecutionListener).

We’re looking at upgrading from Gradle 3.5 to 4.0, and I see that with 4.0, the logging doesn’t appear to be replaced as before. Instead, for each task that executes, I see Gradle’s default logging and my custom logging:

> Task :native:curl:compileCurlxRelExecutableCurlxC
[CCompile  ][  3.2s] curlxC

Was there a change to the behavior of useLogger in v4.0? Or is there another call I have to make in order to squelch the default logs?


(Andrew Richardson) #2

After some GitHub digging, I see that @eriwen did a significant refactor of logging in 4.0 to group output under these task headers. Is there any way to customize the format of (or suppress) the headers?


(Eric Wendelin) #3

Hi Andrew,

I’d say this is an oversight on our part. It would be better to have some --console=something option, but what you can do is change the org.gradle.logging.level=(quiet or warn) and those headers will not be logged.

That may or may not work for you use case. If it doesn’t, would you please file an issue on the gradle/gradle GitHub repo?

Cheers,
Eric


(Andrew Richardson) #4

Thanks for the reply. Setting org.gradle.logging.level=warn suppresses all logs, including my own. I can output my task logs at warn level instead of lifecycle and they will show up, but this feels a bit hacky.

This is what our lifecycle logs look like on 3.5 - each executed task produces a one-line summary of the type of task, the target platform, and the duration.

[CppCompile][  1.9s] linux_x86-64    grpctestCpp
[Executable][  0.2s] linux_x86-64    grpctest
[Install   ][  0.2s] linux_x86-64    grpctest

And this is what they look like with 4.0 - due to the new headers, each task takes 3 lines instead of 1:

> Task :compileGrpctestExecutableGrpctestCpp
[CppCompile][  2.1s] linux_x86-64    grpctestCpp

> Task :linkGrpctestExecutable
[Executable][  0.3s] linux_x86-64    grpctest

> Task :installGrpctestExecutable
[Install   ][  0.2s] linux_x86-64    grpctest

In a project of our scale (hundreds of modules across many cross-compiled platforms), the raw task name is simply not useful - and the columnar output made it much easier to see at a glance what was actually being built.

For what it’s worth, I think the log grouping is incredibly useful at info level and makes things much easier to read. At the lifecycle level though, I wish we had more control to customize how task progress and results are displayed - seems that a lot of that versatility has been lost in the new logging system.