Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I would like to use Project Lombok's log annotation in my Spring Boot projects but I don't want to lose the functionality of being able to change the logging from the application.properties.

The Spring logging docs aren't overly clear on what the default logging implementation should be used, and there are 7 Lombok choices!

Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
324 views
Welcome To Ask or Share your Answers For Others

1 Answer

I would use @Slf4j. Tested the following and it works as expected.

@SpringBootApplication
@Slf4j
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
        log.info("testing logging with lombok");
    }
}

Then you can change the logging level as described here.

logging.level.com.example.DemoApplication=WARN

Note: Below clarifies that SLF4J is correctly handled but point is made in last 5 words!

From the docs:

Default configurations are provided for Java Util Logging, Log4J2 and Logback." ... "By default, If you use the ‘Starters’, Logback will be used for logging. Appropriate Logback routing is also included to ensure that dependent libraries that use Java Util Logging, Commons Logging, Log4J or SLF4J will all work correctly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...