【问题标题】:Spring cloud config server not honoring logging.file property and not logging external fileSpring Cloud 配置服务器不尊重 logging.file 属性并且不记录外部文件
【发布时间】:2020-09-20 03:55:45
【问题描述】:

我使用的是 spring-boot-starter 2.3.3.RELEASE 版本。我在本机配置文件中运行我的 spring 云配置服务器(在文件系统中查找配置文件)。我添加了 logging.file = /var/log/config.log 在 application.properties 文件中。但是我的应用程序没有将日志记录到这个文件中。(所有其他微服务都记录到这个位置)。我是否缺少 Spring 云配置服务器的任何其他设置?非常感谢您的帮助。

【问题讨论】:

    标签: spring spring-boot spring-cloud-config


    【解决方案1】:

    在 spring boot 2.3.3 RELEASE 文档中,指定位置的日志记录属性使用属性指示:

    logging.file.path={path}
    

    文档: https://docs.spring.io/spring-boot/docs/2.3.3.RELEASE/reference/htmlsingle/#boot-features-logging-file-output

    从 logging.path 到 logging.file.path 的这种修改在 Spring Boot 2.2 中显示为弃用: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.2-Release-Notes#deprecations-in-spring-boot-22

    【讨论】:

      【解决方案2】:

      使用 spring-boot 应用程序执行此操作的一种方法是,从命令行参数中将其设置为默认值,它将转储控制台上的所有内容。

      logging.file=logs/test.log
      

      老派但非常有效,将路径保存在 application.properties 中

      logging.file=logs/test.log
      

      【讨论】:

        猜你喜欢
        • 2017-12-10
        • 2015-01-03
        • 2015-06-18
        • 2016-11-26
        • 2020-11-25
        • 2016-01-18
        • 2016-02-07
        • 2017-08-18
        • 2015-02-18
        相关资源
        最近更新 更多