I'm trying to configure my spring boot application with a yaml 'application.yml' file. Everything works perfect except for the logging level configuration.
I've tried this :
logging:
file: /var/log/security.log
level:
org.springframework: OFF
and this :
logging:
file: /var/log/security.log
level.org.springframework: OFF
and thousand of posibilities and nothing works.
is it a bug or maybe I'm doing something wrong???
Thanks
What version of Spring Boot are you using? The logging configuration was only added recently.
I'm using 1.1.4 Release.
The configurations works using properties file but it doesn't work using yaml
The logging.level.* feature was added recently (and application.yml works for that). There is literally nothing that works with application.properties and doesn't with application.yml, so I think you might need to look again and check the precise content and location of your YAML (i.e. is at _actually_ on the classpath?). Is it the level config that isn't working or the file location (or both)?
All the properties in the yml file works (so it is in the classpath ) except the loggin.level.*
application.yml :
server:
port: 8093
context-path: /memento-security-service
spring:
data:
mongodb:
host: localhost
port: 27017
database: memento-security-test
logging:
file: /var/log/memento/security.log
level.org.springframework: OFF
With this setup the server port is 8093, the mongo is connected but I still see the spring framework debug
I have to add this file in the root classpath
application.properties :
logging.level.org.springframework = OFF
With this file the spring logging is disabled, so spring boot is getting the config from application.properties fine but is ignoring the loggin level from application.yml
How about adding the actuator dependency and checking the /env content to see what the Yaml looks like as a property source. It all works fine for me.
Ok, I get the info from /env :
},
"applicationConfig: [classpath:/application-test.properties]": {
"logging.level.org.springframework": "OFF"
},
"applicationConfig: [classpath:/application-test.yml]": {
"spring.data.mongodb.host": "localhost",
"logging.level.org.springframework": false,
"server.port": 8093,
"logging.file": "/var/log/memento/security.log",
"server.context-path": "/memento-security-service",
"spring.data.mongodb.database": "memento-security-test",
"logging.level.com.glass.memento": false,
"spring.data.mongodb.port": 27017
},
"applicationConfig: [classpath:/application.yml]": {
"logging.file": "/var/memento/security.log",
"logging.level.org.springframework": false,
"info": "serviceName:Memento Security Service version:0.29",
"spring.data.mongodb.host": "localhost",
"server.port": 8093,
"spring.data.mongodb.port": 27017,
"server.context-path": "/memento-security-service",
"logging.level.com.glass.memento": false,
"spring.data.mongodb.database": "memento-security"
}
It sets the logging level to "false" in yaml. I found the solution. The config has to be written like this :
logging:
file: /var/memento/security.log
level:
org.springframework: 'OFF'
com.glass.memento: 'OFF'
using 'OFF' instead of OFF
Wow. I guess that's a YAML "feature". Good to know.
Most helpful comment
Ok, I get the info from /env :
It sets the logging level to "false" in yaml. I found the solution. The config has to be written like this :
using 'OFF' instead of OFF