繁体   English   中英

Spring Boot 升级时未发现 log4j 文件问题

[英]log4j file not found issue with spring boot upgrade

我已将 spring boot 从 1.2.8 更新到 1.3.4。

然后我得到 log4j.properties 的 FileNotFoundException。 早些时候,它适用于旧的 Spring Boot 版本。

我在 application.properties 文件所在的资源的同一文件夹下有 log4j.properties 。 在我下面的 application.property 文件中,

logging.config=log4j.properties

在我下面的 pom 文件中,

       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb-log4j</artifactId>
        </dependency>

即使我在 eclipse 依赖层次结构中使用 spring-boot-starter-log4j eclipse 依赖层次结构 它说,log4j:1.2.17(因与 1.2.17 冲突而忽略)[编译]。 但我认为这不是问题。

spring 文档建议您更精确地定义它:试试这个:

logging.config=classpath:log4j.properties

编辑

另一个建议是将配置名称更改为“log4j-spring.properties”,原因如下:

如果可能,我们建议您将 -spring 变体用于日志记录配置(例如 logback-spring.xml 而不是 logback.xml)。 如果使用标准配置位置,Spring 无法完全控制日志初始化。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM