Problem with slf4j logging

I have written a custom gradle plugin with some custom gradle tasks that I can apply in my other project with:

apply plugin: 'myplugin'

In the tasks I would like to start using slf4j logging so I have done:

import org.gradle.api.DefaultTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
  public class MyTask extends DefaultTask {
  Logger logger = LoggerFactory.getLogger(MyTask.class);
  void mytask() {

I have the following logback.xml in the root of the myplugin project with the above task:

<?xml version="1.0" encoding="UTF-8"?>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
    <root level="DEBUG">
              <appender-ref ref="STDOUT" />

But when I apply the ‘myplugin’ in another project and run the task: 'MyTask ’ it simply prints:


Why are the messages not formatted according to the logback.xml file?

The Gradle logging system doesn’t support logback.xml and similar logging configuration files. What you see solely depends on the log level set when running Gradle (or configured in the build script).

Ok so doing log messages in custom task/plugins needs to be done using system.out?

No, just use the appropriate log level. Printing to system out is the same as logging on level ‘org.gradle.api.logging.LogLevel.QUIET’.

Hm I am a bit confused, The documentation says it uses slf4j:

and looking into the lib folder of gradle 1.3 it contains logback and slf4j. So has gradle been updated to use slf4j?

SLF4J is the API, and logback the implementation.

Ah misread your post, it was only that the logback.xml was not supported. I am now using :


to get access to the slf4j methods+ “quiet(message)”.

If you wish to leverage the Gradle-provided log levels, that’s the way to go.