[Spring boot] using the annotation @ Slf4j

Notes @ Slf4j use

 

If you do not have to write every time

Final Logger Logger Private = LoggerFactory.getLogger (.class current class name);

Notes @ Slf4j can be used to print the log.

 

====================================== how to use it? ==========================================

1. Lombok need to install the plug-in on your IDEA

https://www.cnblogs.com/sxdcgaq8080/p/7884477.html

 

2. The introduction of jar lombok in your springboot project

    <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

 

 

3. @ Slf4j add annotations in any class, and may be any of the printing log in the method of the present class

/ ** 
 * @author SXD 
 * @date 2019/8/2 13:58 
 * / 
@ SLF4J 
@RestController (value = "/ Test" )
 public  class TestController { 
    
    
    @RequestMapping (value = "/ TestPrint", Method = RequestMethod. the GET)
     public String TestPrint () { 
        log.debug ( "print log can directly call the log" );
         return "TestPrint" ; 
    } 
    
}

 

Guess you like

Origin www.cnblogs.com/sxdcgaq8080/p/11288213.html