A dedicated annotation processor SLF4J implementation which delegates logging to javax.annotation.processing.Messager
.
-
Add the dependency to your annotation processor project
<dependency> <groupId>com.cosium.logging</groupId> <artifactId>annotation-processor-logger</artifactId> <version>${annotation-processor-logger.version}</version> </dependency>
-
Make your
javax.annotation.processing.Processor
extendcom.cosium.logging.annotation_processor.AbstractLoggingProcessor
public class MyProcessor extends AbstractLoggingProcessor { protected boolean doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { // Make the world a better place } }
-
Use SLF4J as usual
In the Maven project using your annotation processor, enable showWarnings
in maven-compiler-plugin
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
</plugins>
</build>