简体   繁体   中英

spring restful web service logging

I implemented Spring RESTful Web Service using this tutorial: https://spring.io/guides/gs/rest-service/ . I added dependencies for log4j in pom.xml and log4j.properties file in src/main/resources folder. Now I expect logging to be done into log file as stated inthe log4j.properties file instead of to STDOUT. However, logging goes only to STDOUT. How can I fix tis to print log messages to log file?

By default Spring Boot uses LogBack as logging framework. If you want to configure Log4J, follow this configuration . You need to exclude Spring Boot's logging module (containing LogBack dependency) and include Spring boot started for log4j.

BTW, log4j is ancient technology, consider moving to logback or log4j2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM