gpt4 book ai didi

java - 如何为 spring-boot 应用程序设置 logging.path?

转载 作者:搜寻专家 更新时间:2023-11-01 04:04:02 24 4
gpt4 key购买 nike

spring-boot 提供了几个可以在 application.properties 中应用的 logging.* 设置,例如:

logging.level.=DEBUG
logging.file=myfile.log
logging.path=d:/logs/

问题:myfile.log 已生成,但在类路径中!为什么 spring 不考虑我的绝对路径?

最佳答案

Spring Boot documentation

By default, Spring Boot will only log to the console and will not write log files. If you want to write log files in addition to the console output you need to set a logging.file or logging.path property (for example in your application.properties).

然后描述了 logging.filelogging.path 属性是如何工作的。你应该只设置一个。

如果设置了 logging.file,它将写入该特定文件。文档说明

Names can be an exact location or relative to the current directory.

因此您可能正在写入当前目录,该目录恰好与您的类路径相同。

如果你设置logging.path,Spring Boot

Writes spring.log to the specified directory. Names can be an exact location or relative to the current directory.

如果您不希望它们混合,请检查您当前的目录是否不是您的类路径,并调整 logging.filelogging.path 之一因此。

关于java - 如何为 spring-boot 应用程序设置 logging.path?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40913788/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com