This is very simple question, but I cannot find information.
(Maybe my knowledge about Java frameworks is severely lacking)
How can I set the logging level with application.properties?
And logging file location, etc?
This is very simple question, but I cannot find information.
(Maybe my knowledge about Java frameworks is severely lacking)
How can I set the logging level with application.properties?
And logging file location, etc?
Update: Starting with Spring Boot v1.2.0.RELEASE, the settings in
application.properties
orapplication.yml
do apply. See the Log Levels section of the reference guide.For earlier versions of Spring Boot you cannot. You simply have to use the normal configuration for your logging framework (log4j, logback) for that. Add the appropriate config file (
log4j.xml
orlogback.xml
) to thesrc/main/resources
directory and configure to your liking.You can enable debug logging by specifying
--debug
when starting the application from the command-line.Spring Boot provides also a nice starting point for logback to configure some defaults, coloring etc. the base.xml file which you can simply include in your logback.xml file. (This is also recommended from the default logback.xml in Spring Boot.
In case you want to use a different logging framework, log4j for example, I found the easiest approach is to disable spring boots own logging and implement your own. That way I can configure every loglevel within one file, log4j.xml (in my case) that is.
To achieve this you simply have to add those lines to your pom.xml:
You probably already have the first dependency and only need the other two. Please note, that this example only covers log4j.
That's all, now you're all set to configure logging for boot within your log4j config file!
Making sure Dave Syer tip gets some love, because adding
debug=true
to application.properties will indeed enable debug logging.In case of eclipse IDE and your project is maven, remember to clean and build the project to reflect the changes.
For the records: the official documentation, as for Spring Boot v1.2.0.RELEASE and Spring v4.1.3.RELEASE:
The proper way to set the root logging level is using the property
logging.level.root
. See documentation, which has been updated since this question was originally asked.Example: