java - 如何在 application-{profile}.properties 文件中包含 log4j-{profile}.properties 文件
问题描述
我有两个特定于配置文件的 application.properties 文件(application-dev.properties 和 application-prod.properties)和两个 log4j.properties 文件。(Log4j-dev.properties 和 Log4j-prod.properties)。我需要在 application-dev.properties 文件中包含 log4j-dev.properties 文件。我怎样才能做到这一点?
解决方案
您可以使用logging.level.*
. 使用spring-boot-starter-logging
依赖。
logging.level.org.springframework=DEBUG
logging.level.com.howtodoinjava=DEBUG
#output to a temp_folder/file
logging.file=${java.io.tmpdir}/application.log
# Logging pattern for the console
logging.pattern.console= %d{yyyy-MM-dd HH:mm:ss} - %msg%n
# Logging pattern for file
logging.pattern.file= %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%
另一种解决方案是您可以使用链接到外部 log4j 配置文件logging.config=log4j.properties
因此,例如在application-dev.properties
创建行中:
logging.config=classpath:Log4j-dev.properties
并在application-prod.properties
创建行:
logging.config=classpath:Log4j-prod.properties
推荐阅读
- php - 如何在网页上显示特定的一组 wordpress 帖子?
- java - 通过 HTTPS 打开 Trip Planner
- java - 如何使用 JAVA EE 获取用于下载文件的 HttpServletResponse 实例
- php - setcookie() 期望参数 3 为整数,给定数组
- powerbi - 创建度量以根据按日期查找计算值
- python - 如何在网页上自动选择数据并使用 Python 下载生成的 xls 文件
- python - 在 Django 中定义视图和 URL。为什么不使用括号来调用函数?
- r - 是否可以延长 R 中 x 轴的间隔?
- python - 类范围的异常处理程序
- spring-boot - AOP(AspectJ)中通过注解访问函数参数