diff options
6 files changed, 22 insertions, 2 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index 1cd933e3..583aa0af 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -191,7 +191,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleLog4j2Log extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j2> { @Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, ""); + processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, annotation.getInstance().value()); } } diff --git a/src/core/lombok/extern/log4j/Log4j2.java b/src/core/lombok/extern/log4j/Log4j2.java index 2a0f09e1..96fab793 100644 --- a/src/core/lombok/extern/log4j/Log4j2.java +++ b/src/core/lombok/extern/log4j/Log4j2.java @@ -59,4 +59,8 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.SOURCE) @Target(ElementType.TYPE) public @interface Log4j2 { + /** + * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. + */ + String value() default ""; }
\ No newline at end of file diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index b01dd564..a5d12964 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -141,7 +141,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleLog4j2Log extends JavacAnnotationHandler<lombok.extern.log4j.Log4j2> { @Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, ""); + processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, annotation.getInstance().value()); } } diff --git a/test/transform/resource/after-delombok/LoggerLog4j2.java b/test/transform/resource/after-delombok/LoggerLog4j2.java index 7e4c01de..8473134b 100644 --- a/test/transform/resource/after-delombok/LoggerLog4j2.java +++ b/test/transform/resource/after-delombok/LoggerLog4j2.java @@ -5,4 +5,8 @@ class LoggerLog4j2 { class LoggerLog4j2WithImport { @java.lang.SuppressWarnings("all") private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2WithImport.class); +} +class LoggerLog4j2WithDifferentName { + @java.lang.SuppressWarnings("all") + private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger("DifferentName"); }
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerLog4j2.java b/test/transform/resource/after-ecj/LoggerLog4j2.java index c1368e5d..3243ef2d 100644 --- a/test/transform/resource/after-ecj/LoggerLog4j2.java +++ b/test/transform/resource/after-ecj/LoggerLog4j2.java @@ -14,4 +14,12 @@ import lombok.extern.log4j.Log4j2; LoggerLog4j2WithImport() { super(); } +} +@Log4j2("DifferentName") class LoggerLog4j2WithDifferentName { + private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger("DifferentName"); + <clinit>() { + } + LoggerLog4j2WithDifferentName() { + super(); + } }
\ No newline at end of file diff --git a/test/transform/resource/before/LoggerLog4j2.java b/test/transform/resource/before/LoggerLog4j2.java index b7ea99ee..13b3605f 100644 --- a/test/transform/resource/before/LoggerLog4j2.java +++ b/test/transform/resource/before/LoggerLog4j2.java @@ -6,4 +6,8 @@ class LoggerLog4j2 { @Log4j2 class LoggerLog4j2WithImport { +} + +@Log4j2("DifferentName") +class LoggerLog4j2WithDifferentName { }
\ No newline at end of file |