Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 如何使用yaml将当前日期放在logback文件名中?_Spring Boot_Logging_Yaml_Logback_Spring Logback - Fatal编程技术网

Spring boot 如何使用yaml将当前日期放在logback文件名中?

Spring boot 如何使用yaml将当前日期放在logback文件名中?,spring-boot,logging,yaml,logback,spring-logback,Spring Boot,Logging,Yaml,Logback,Spring Logback,在springboot中,我试图在日志文件名lke中输入当前日期:2020-01-31-log.log 我试过这个: logging: level: root: info com.inyt.inytcirculationportal: debug file: name: "logs/%d-log.log" 但是似乎什么都不起作用。像这样将日期放入日志文件对我来说似乎不是一个好主意,即使您能够以某种方式将其注入到您的属性中 如果您的应用程序运行几天或几个月怎么办?

在springboot中,我试图在日志文件名lke中输入当前日期:
2020-01-31-log.log

我试过这个:

logging:
  level:
    root: info
    com.inyt.inytcirculationportal: debug
  file:
    name: "logs/%d-log.log"

但是似乎什么都不起作用。

像这样将日期放入日志文件对我来说似乎不是一个好主意,即使您能够以某种方式将其注入到您的属性中
如果您的应用程序运行几天或几个月怎么办?如果在午夜重新启动应用程序,则每天只能获得一个文件。如果您还没有这样做,我建议您查看Logback,它将自动归档您当前的日志文件,并在您配置的时间间隔内启动一个新的日志文件。 根据您提到的日期模式,您的日志文件夹可能如下所示:

  • app.log