Logging.config configuration for spring boot

I wanted to configure the location of the log4j.xml file in my spring boot application. To do this, I added the logging.config property to my application.properties configuration, specifying the path to the log4j.xml file. But it looks like this property is being ignored. But it should work according to spring boot docs:

logging.config= # location of config file (default classpath:logback.xml for logback)

Did I do something wrong?

+4
source share
3 answers

Spring , , . logback , log4j spring-boot-starter-log4j . , maven :

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
            <version>1.2.4.RELEASE</version>
</dependency>

log4j 1.x:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
            <version>1.2.4.RELEASE</version>
</dependency>

logging.config application.properties:

logging.config = classpath:path/to/log4j.xml
+3

, (logback.xml) : . : script, . , , , . script: - spring.config.location =/configPath/application.properties , Spring. - , , :)

+2

spring :

, , Logback, Log4j.

:

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

All Articles