我正在尝试创建一个将 API 访问信息输出到记录器文件的记录器。我创建了一个日志文件:<?xml version="1.0" encoding="UTF-8"?><configuration> <include resource="org/springframework/boot/logging/logback/defaults.xml" /> <property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/> <include resource="org/springframework/boot/logging/logback/file-appender.xml" /> <root level="INFO"> <appender-ref ref="FILE" /> </root></configuration>应用程序.yml:logging:file: restapi.log控制器:@RestControllerpublic class ProductController { @Autowired ProductRepository productRepository; //creating a new logger private final Logger logger = LoggerFactory.getLogger(ProductController.class); @GetMapping("/products") public ProductsResponse getAllProducts() { //logging an event logger.info("abcdefg"); List<Product> foundProducts; foundProducts = productRepository.findAll(); }每次在我的控制器中运行特定方法时,我都想输出到日志文件。目前,我运行服务器,它在测试模式下运行,服务器由于某种原因停止,所以我不知道如何发送请求。
添加回答
举报
0/150
提交
取消