【发布时间】:2019-06-06 11:00:15
【问题描述】:
我最近升级了我的应用程序以使用 Spring Boot 2.1.1.RELEASE 和 JDK 11 和 tomcat 9.0.14。从那时起,日志记录不起作用。之前一切都很好。下面是我试图开始工作的简单日志记录。
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class LoggingController {
private static final Logger logger = LogManager.getLogger(LoggingController.class);
@RequestMapping("/")
public String index() {
logger.info("This is an INFO message.");
logger.warn("This is a WARN message.");
logger.error("You guessed it, an ERROR message.");
logger.trace("This is a TRACE message.");
logger.debug("This is a DEBUG message.");
return "Welcome to Spring Logging! Check the console to see the log messages.";
}
}
根据link,我在application.properties中添加了以下内容
logging.level.web=debug
还有什么改变吗?我可以看到日志记录确实适用于 slf4j 导入
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
但我不想在我的整个应用程序中更新它。
【问题讨论】:
标签: java apache spring-boot logging apache-commons-logging