Harshana
Harshana

Reputation: 7647

log4j file not found issue with spring boot upgrade

I have update spring boot to 1.3.4 from 1.2.8.

Then i get a FileNotFoundException for log4j.properties. Earlier it work with old spring boot version.

I have log4j.properties under same folder of resource which application.properties file resides. In application.property file i have below,

logging.config=log4j.properties

In pom file i have below,

       <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>

Even i use spring-boot-starter-log4j, in eclipse dependency hierarchy eclipse dependency hierarchy it says, log4j: 1.2.17 (ommitted for conflict with 1.2.17) [compile]. But i think its not the issue.

Upvotes: 1

Views: 718

Answers (1)

Jaiwo99
Jaiwo99

Reputation: 10017

The spring documentation suggests you to define it more precisely: try this:

logging.config=classpath:log4j.properties

EDIT:

Another suggestion would be change the name of the config to `log4j-spring.properties' here is the reason:

When possible we recommend that you use the -spring variants for your logging configuration (for example logback-spring.xml rather than logback.xml). If you use standard configuration locations, Spring cannot completely control log initialization.

Upvotes: 1

Related Questions