简体   繁体   中英

Where does Spring Boot store its default logging settings

I'm creating a Java Spring Boot 2.X application. In my configuration (application.yml), I have added the following property:

logging:
    file: ${spring.applicaton.name}.log

This seems to work out of the box. However, I'm curious where the underlying default log configurations reside. Using google I found out that Spring Boot uses logback, but I cannot see a logback-spring.xml file. Also this other question seems to mention log4j2 instead of logback - does that work because they added a dependency on log4j2 (I have not added any dependency except for the sprint boot starter). what I also observed is that the two main logging mechanisms seem to be a rolling file appender and the console logger. Where is this defined?

My question is: where does Spring Boot pick up its default log configuration? I found these configuration files but I'm not sure if they are correct. Their naming convention and syntax is not what I expected. how do you choose a specific logging implementation - by dependencies or by configuration?

The default Logback configuration is stored in:

spring-boot-2.1.1.RELEASE.jar
    /org/springframework/boot/logging/logback/base.xml

The default Log4j2 configuration is stored in:

spring-boot-2.1.1.RELEASE.jar
    /org/springframework/boot/logging/log4j2/log4j2-file.xml

The default Java Util Logging configuration is stored in:

spring-boot-2.1.1.RELEASE.jar
    /org/springframework/boot/logging/java/logging-file.properties

Note: The version of the jar file varies, of course.

Spring defaults to Logback. Read the Spring documentation for how to specify a different implementation and for how to configure it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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