#logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger{15} ===> %msg%n logging.pattern.dateformat=yyyy-MM-dd HH:mm:ss.SSS #设置为Debug就会非常详细 #logging.level.root=debug #默认为INFO #精确设置某个包下的日志级别 logging.level.com.example.demo.controller=debug #只写名字,不写位置,默认在与项目module同级别位置 #既能指名字又能指定路径 logging.file.name=demo.log #写了file.name的情况下path就不生效了 #写了位置,会落在对应的文件位置 #logging.file.path=C:\\myLog #归档,切割配置Log文件 logging.logback.rollingpolicy.file-name-pattern=${LOG_FILE}.%d{yyyy-MM-dd},%i.gz #达到切割级别或者标准就会切割文件 logging.logback.rollingpolicy.max-file-size=1MB
#logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger{15} ===> %msg%n
logging.pattern.dateformat=yyyy-MM-dd HH:mm:ss.SSS
#设置为Debug就会非常详细
#logging.level.root=debug
#默认为INFO
#精确设置某个包下的日志级别
logging.level.com.example.demo.controller=debug
#只写名字,不写位置,默认在与项目module同级别位置
#既能指名字又能指定路径
logging.file.name=demo.log
#写了file.name的情况下path就不生效了
#写了位置,会落在对应的文件位置
#logging.file.path=C:\\myLog
#归档,切割配置Log文件
logging.logback.rollingpolicy.file-name-pattern=${LOG_FILE}.%d{yyyy-MM-dd},%i.gz
#达到切割级别或者标准就会切割文件
logging.logback.rollingpolicy.max-file-size=1MB
package com.example.demo.controller; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController @Slf4j public class HelloController { @GetMapping("/h") public String hello(String a,String b){ for (int i = 0; i < 10000; i++) { // Logger logger = LoggerFactory.getLogger(HelloController.class); // logger.info("哈哈哈"); log.trace("trace日志"); log.debug("debug日志"); // SpringBoot默认的日志级别 log.info("info日志,参数A:{}B:{}",a,b); log.warn("warn日志"); log.error("error日志"); } return "Hello"; } }
package com.example.demo.controller; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController @Slf4j public class HelloController { @GetMapping("/h") public String hello(String a,String b){ for (int i = 0; i < 10000; i++) { // Logger logger = LoggerFactory.getLogger(HelloController.class); // logger.info("哈哈哈"); log.trace("trace日志"); log.debug("debug日志"); // SpringBoot默认的日志级别 log.info("info日志,参数A:{}B:{}",a,b); log.warn("warn日志"); log.error("error日志"); } return "Hello"; } }
package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }