gpt4 book ai didi

java - 如何在 application-{profile}.properties 文件中包含 log4j-{profile}.properties 文件

转载 作者:行者123 更新时间:2023-12-02 10:34:10 40 4
gpt4 key购买 nike

我有两个特定于配置文件的 application.properties 文件(application-dev.properties 和 application-prod.properties)和两个 log4j.properties 文件。(Log4j-dev.properties 和 Log4j-prod.properties)。我需要在 application-dev.properties 文件中包含 log4j-dev.properties 文件。我怎样才能做到这一点?

最佳答案

您可以使用 logging.level.* 在 application-*.properties 中配置 Spring Boot 应用日志记录。使用 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%

另一个解决方案是您可以使用 logging.config=log4j.properties 链接到外部 log4j 配置文件

例如,在 application-dev.properties 中创建以下行:

logging.config=classpath:Log4j-dev.properties

并在application-prod.properties中创建以下行:

logging.config=classpath:Log4j-prod.properties

关于java - 如何在 application-{profile}.properties 文件中包含 log4j-{profile}.properties 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53406295/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com