我有几个Spring Boot应用程序部署在独特的Tomcat中。 每个应用程序被配置成与包含客户代码Spring Boot:在logback配置中使用Tomcat上下文参数
<Context path="/myApp1" reloadable="false">
<Parameter name="CUSTOMER_CODE" value="CUSTOMER1" />
</Context>
我希望每个客户具有基于在context.xml中定义的代码单独的日志一个context.xml文件。
不幸的是这个配置并不在我的logback-config.xml中工作:
<property name="LOG_FILE" value="${ROOT_LOG}/${CUSTOMER_CODE}/myApp.log}"/>
CUSTOMER_CODE_IS_UNDEFINED在 “ROOT_LOG” 目录下创建一个文件夹。 “ROOT_LOG”由系统属性提供。
有什么办法可以使这个logback配置工作吗?
在application.properties中定义的属性的使用效果很好(我将logback.xml重命名为logback-spring.xml)。在我看来,在初始化日志之前,Spring引导不会在Environnement中设置Tomcat上下文参数。任何想法的解决方法?谢谢。
我觉得定制的logback配置(的logback -spring.xml)将执行您所需的操作:https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html#boot-features-custom-log-configuration - 主要你可能只需要重命名你的配置文件。 – cjstehno
感谢您的回答。我尝试了logback-spring.xml,但没有奏效。我更新了帖子以添加更多信息。 – ngu