Example of using LogBack and SLF4j in your Gradle project

I put together a little quick-start for using SLF4j and LogBack with Gradle. I thought it might help someone out there. https://gist.github.com/djangofan/4747929

If there is a better way to handle logging in unit tests , such as a built-in method in Gradle, can anyone share their ideas here?

Not related to Gradle, but Groovy provides a @Slf4j transformation reducing the amount of code needed to initialize a logger:

import groovy.util.logging.Slf4j

@Slf4j

class A

{

log.info( ’ … ’ )

}

Excellent. Thanks for sharing. If I ever do a Groovy project I will certainly use that.

I’m interested in the quickstart example you put together but I had a few questions.

Is the intent to replace the default gradle logging system with logback?

If so, why is there no gradle.useLogger(new CustomEventLogger())?

With this configuration could you create different appenders for all gradle message traffic thereby allowing the application messages to not be swamped by gradle internal output?