stay JAVA Backstage , One of the most frequently used tools is the code that outputs logs . In the beginning , I use it System.out.println()
Output log , It turns out that , The real God doesn't use it when it outputs logs . It's a kind of encapsulated code log.info();
I'm interested in this way of outputting logs . Only after research did we know , This is log4j For the output log api, Then in the company project , I use this tool class many times . But as time goes on , More and more I found out , There are many ways to output logs , such as logger.info();
log.error(); So I'm going to find out …

* The most primitive method System.out.println(“ Here is the output log ”);
* Common methods public class ApplicationStarter { // Create log implementation class package
org.slf4j.LoggerFactory org.slf4j.Logger; private static Logger logger =
LoggerFactory.getLogger(ApplicationStarter.class); public static void main(
String[] args) { SpringApplication.run(ApplicationStarter.class, args); // Print log
logger.debug("\n"+" Start successfully !---------------------------"); }
* PlayFrameWork The framework comes with a tool class Logger.info(“》》》 Successful execution ”); // From bag play.Logger
* Lombok Self logging tool @Slf4j @Configuration public class RedisConfig extends
CachingConfigurerSupport { log.info("test"); // From bag lombok.extern.slf4j.Slf4j }

Technology