deakandris
deakandris

Reputation: 85

Cannot change Spring Boot logging level from application.properties but can from logback.xml

We have a multi-module Spring Boot project and it has DEBUG level logging that need to be changed to INFO level. As it uses Spring Boot 1.2.5, I followed the instructions here and here, but setting logging.level.org.springframework.web=INFO in application.properties has no effect and we keep getting DEBUG messages in the log.

However, providing a logback.xml like the one on the above mentioned site and setting the level there works. Even without setting it explicitly, as the base.xml that comes with Spring Boot and is included in our logback.xml has the root logging level set to INFO by default.

Spring Boot uses SLF4J with Logback as default but we do not want to depend on Logback just because of this and we should be able to configure logging level from application.properties. The project is configured programatically so application.properties does not contain anything else. Both configuration files are in the classpath under src/main/resources.

I have tried with logging.level.*=INFO, tried different delimiters (:, , =). I have searched though the project files but have found no traces of existing log configuration.

What can cause that application.properties is being ignored/overidden but logback.xml is not?

application.properties

logging.level.org.springframework.web=INFO

logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
</configuration>

Upvotes: 2

Views: 3445

Answers (2)

Marged
Marged

Reputation: 10953

Try to set the name of the application.properties file to use with either spring.config.location or spring.config.name (see docs for details)

Besides that you can use the /env endpoint of Actuator to see which files are processed by Spring Boot and which values are read from them. This will tell you if there are more configuration file than you provide.

Perhaps a quick check might help: check something in the application.properties, for example server.port=4711, then you will know immediately if the file is read or not.

Keep in mind that some logging output gets written before application.properties is read. That means some org.springframework.web messages might be already written before Spring Boot learns that you don't want to see them.

Upvotes: 1

Anton N
Anton N

Reputation: 2375

If you put logback.xml Spring Boot will use Logback as primary LoggingSystem. Spring Boot has no mandatory logging dependence, except for the commons-logging API.

Upvotes: 0

Related Questions