Lifecycle to Console and Info to File?


(Peter Kahn) #1

Is it still impossible to alter gradle log output or configure it to set a console appender for Lifecycle and file Appender for Info? Logging to file and console asked the question in the old form and on stackoverflow I see that this is described as not configurable.

I’m looking at the gradle source to see how I could override, the only thing that might work would be to redefine the class with a -I reallyBadIdeaLogger.groovy but that seems unwise.

My other option would be to redirect all to a file are parse it (not ideal either).

The problem I face is to keep Jenkins console log for Errors and critical data with enough information an a stored file for debug analysis. This is a problem that every build hits and ant had a great record task that made this a snap. Both maven and gradle use logging frameworks that should allow this, but neither seems to expose this feature.

Please let me know if you have any ideas. If I figure out something that isn’t a horrible kludge, I’ll answer my own question.


(Peter Kahn) #2

Here’s one way it could work

  1. Jenkins these two actions in a parallel block
  • runs gradle and redirects to file (./gradlew -d … > gradle.log)
  • shell tail file + grep for [LIFECYCLE] / ERROR/ INFO, sed strips the logging format and prints those to console.

Result: jenkins console contains lifecycle only, file contains full debug.
Problems: kludgy, performance hit perhaps due to debug output