【问题标题】:log4j file not found issue with spring boot upgrade春季启动升级未找到 log4j 文件问题
【发布时间】:2016-09-03 17:47:27
【问题描述】:

我已将 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>

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

【问题讨论】:

    标签: java spring maven spring-boot


    【解决方案1】:

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

    logging.config=classpath:log4j.properties

    编辑:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-04
      • 1970-01-01
      • 2020-10-23
      • 2021-12-30
      • 1970-01-01
      • 1970-01-01
      • 2019-05-23
      相关资源
      最近更新 更多