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

标签 java spring spring-boot

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/

相关文章:

json - 在 spring mongo db 查询中指定字段投影

spring-boot - 在primefaces上将selectManyButton与elasticSearch一起使用

java - 在java中使用TCP通过字节数组传输二进制文件

java - 自动为 @Embeddable 类的列名添加前缀

java - 调用实体管理器时出现空指针

java - 无法在Maven项目中加载JDBC驱动程序类[com.microsoft.sqlserver.jdbc.SQLServerDriver]

java - 内修复表达式计算 - NoSuchElementFound 异常

java - 在界面中使用@RequestMapping 是不是一个坏主意?

java - 错误 : Could not find or load main class . .. 在 Spring Boot 1.5.9 版本中,但在 1.4.7 版本中没有

java - Spring Data Reactive Mongo : Class type converter