How to Configure Slf4j Logging in a Custom Plugin

plugins

(Gary Price) #1

I have written a Gradle custom plugin that uses Slf4j for logging. More precisely, it uses a 3rd-party library as part of a task it adds to the projects that use the plugin. It is the 3rd-party library that uses SLf4j, and I would prefer not to change it. I have so far been unsuccessful getting the logging to work. I have provided logback-classic as a dependency of the plugin in the build script in the project where the plugin is used, and used the -D command line argument to Gradle to provide the location of the logback.xml configuration file via a system property. This configuration file provides a console appender, at the DEBUG level. It also contains debug=“true” at the configuration node of the XML, and uses a StatusListener as recommended here for debugging. This produces no output at all, so it is obvious I am getting something very basic wrong. I looked at the similar topics on this forum and they didn’t seem to help. I feel that it should be possible to configure Slf4j logging in a plugin in the project where it is used. That is, provide the logging implementation and configure it. Can that be done? I am using Gradle 2.13.