#设定日志的默认级别为info logging.level.root=info #设定org包下的日志级别为warn logging.level.org=warn #设定com.ch.ch4_1包下的日志级别为debug logging.level.com.ch.ch4_1=debug logging.file=d:/log/my.log logging.pattern.console=%level %date{yyyy-MM-dd HH:mm:ss:SSS} %logger{50}.%M %L :%m%n logging.pattern.file=%level %date{ISO8601} %logger{50}.%M %L :%m%n
package com.tszr.controller; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class LogTestController { private Log log = LogFactory.getLog(LogTestController.class); @RequestMapping("/testLog") public String testLog() { log.info("测试日志"); return "测试日志" ; } }