1 /*
2 * Copyright (C) 2010-2025 The Project Lombok Authors.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22 package lombok.extern.java;
23
24 import java.lang.annotation.ElementType;
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 import java.lang.annotation.Target;
28
29 import lombok.AccessLevel;
30
31 /**
32 * Causes lombok to generate a logger field.
33 * <p>
34 * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>.
35 * <p>
36 * Example:
37 * <pre>
38 * @Log
39 * public class LogExample {
40 * }
41 * </pre>
42 *
43 * will generate:
44 *
45 * <pre>
46 * public class LogExample {
47 * private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LogExample.class.getName());
48 * }
49 * </pre>
50 *
51 * This annotation is valid for classes and enumerations.<br>
52 * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/util/logging/Logger.html">java.util.logging.Logger</a>
53 * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/util/logging/Logger.html#getLogger-java.lang.String-">java.util.logging.Logger#getLogger(java.lang.String)</a>
54 * @see lombok.extern.apachecommons.CommonsLog @CommonsLog
55 * @see lombok.extern.log4j.Log4j @Log4j
56 * @see lombok.extern.log4j.Log4j2 @Log4j2
57 * @see lombok.extern.slf4j.Slf4j @Slf4j
58 * @see lombok.extern.slf4j.XSlf4j @XSlf4j
59 * @see lombok.extern.jbosslog.JBossLog @JBossLog
60 * @see lombok.extern.flogger.Flogger @Flogger
61 * @see lombok.CustomLog @CustomLog
62 */
63 @Retention(RetentionPolicy.SOURCE)
64 @Target(ElementType.TYPE)
65 public @interface Log {
66 /**
67 * Sets the access level of the generated log field.
68 * Default: {@code AccessLevel.PRIVATE}.
69 *
70 * @return The constructed Logger method will be generated with this access modifier.
71 */
72 AccessLevel access() default AccessLevel.PRIVATE;
73
74 /** @return The category of the constructed Logger. By default, it will use the type where the annotation is placed. */
75 String topic() default "";
76 }