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);
@TaskAction
void mytask() {
logger.error("logback-error");
logger.warn("logback-warn");
logger.info("logback-info");
I have the following logback.xml in the root of the myplugin project with the above task:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration>
But when I apply the ‘myplugin’ in another project and run the task: 'MyTask ’ it simply prints:
logback-error
:clean
logback-warn
Why are the messages not formatted according to the logback.xml file?