-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to set log level for specific task #1010
Comments
I know that the following is based on internal APIs....
That did change the logging level but had no change on what is logged. |
Now that I'm trying to get remote cache working with my language plugin, the ability to switch on debug-level logging for a single task would be oh-so-helpful. |
Additionally, I'd find it very useful to be able to set this from the command line. |
Let all samples use configuration avoidance APIs and DSL
Is this still an issue? |
I can confirm this issue still persists with gradle 5.5.1 |
@NicolasRouquette i tried the opposite of what you did. in the command line i passed the flag --info, and i added the following code
And that changes the log level and the output. Not exactly what we want to accomplish, but it is a bit helpful. Surprisingly it works fine when going from info to lifeCycle, but not the other way around. |
4 years, 52 votes and no progress. I ask me as plugin developer if I should ignore Gradle logging setting and do my own thing. The follow code would work:
|
@Horcrux7 That is exactly what we chose to do within our plugin : https://github.com/project-ncl/gradle-manipulator/blob/master/common/src/main/java/org/jboss/gm/common/logging/GMLogger.java |
Up to gradle 6.7.1 there was a workaround to use deprecated replaceLogger method Unfortunately 6.8 removed deprecated method by replacing it with decorateLogger and than replaced with setLoggerMessageRewriter which isn't called for all messages. And just to add another usecase to the feature request: when runing Android Tests on Android device, the related Gradle task ( |
@mateuszkwiecinski The Also see this related issue #13090 |
Is there any update on this? It is a very useful feature as you get tons and tons of debug logging if you do not reduce to a task |
@mateuszkwiecinski could you share details on how did you do that? |
@DenBond7 - Here's my implementation: https://github.com/otwarty-wykop-mobilny/wykop-android/blob/8525b12222f0a3ab27105a96606722bc7a73c54d/buildSrc/src/main/kotlin/com/android/build/gradle/internal/LoggerWrapper.kt#L36 (I'm not sure if this still works though after all dependency updates over last year 😛 but the general idea persists - to override AGP's class with configurable logger). |
In a def debug = project.findProperty('debug')
if (debug) {
def debugTasks = debug.tokenize(',')
gradle.taskGraph.whenReady { taskGraph ->
for (task in taskGraph.allTasks) {
if (task.name in debugTasks) {
logger.lifecycle("[${task.path}] Debug mode enabled")
task.logger.metaClass.info = { String message, Object... objects ->
task.logger.lifecycle(message, objects)
}
}
}
}
} Apparently Groovy metaClass does not work with Java objects. |
I am interested in this feature too. |
This is sorely needed. Debugging an issue with a single task currently requires increasing the log verbosity of the entire (potentially large) build. |
another good option would be to set a level e.g via org.gradle.logging.level.my.package.name.or.fqcn=INFO or the equivalent via GRADLE_OPTS="-Dorg.gradle.logging.level.my.package.name.or.fqcn=INFO" |
Gradle team, please consider giving this 8 yo issue some attention it would considerably simplify users' ability to leverage the Gradle cache. |
It's almost 11 years old, when you consider that this issue was almost four years old when it was migrated from Jira issue (GRADLE-2658)[https://issues.gradle.org/browse/GRADLE-2658] to this current GitHub issue. |
Would be a very useful feature. |
+1 |
As a user, I would like to be able to debug just one specific task. Something like:
Expected Behavior
Given the build file above, I'd like "Output on INFO level" to be printed if I run
gradle myTask
Current Behavior
Currently, "Output on INFO level" is not logged.
Context
This was submitted by @etiennestuder in GRADLE-2658 with 5 votes.
Your Environment
The text was updated successfully, but these errors were encountered: