Reputation: 3849
I am trying to turn off the console output in STS for a spring boot application using the application.properties file.
Setting the value logging.level.root does seem to have some effect but I can never turn it off completely and nor can I turn off the auto configuration report output.
logging.level.root=OFF
spring.main.banner-mode=OFF
[email protected]@
The banner does get turned off by the property spring.main.banner-mode.
For some reason with the above properties I still get DEBUG output from spring on startup:
2017-05-09 15:33:16.744 DEBUG 11772 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application started with classpath:
2017-05-09 15:33:16.798 DEBUG 11772 --- [ main] o.s.boot.SpringApplication : Loading source class
There are more lines telling me which properties files are being loaded but I dont want to fill up this post with them.
Following from this I then get the autoconfiguration report output.
I am wondering if I have a configuration issue and if this would cause spring to continue to output on start up?
Upvotes: 21
Views: 19932
Reputation: 301
For those who still couldn't fix problem. I was calling jar file to create some objects. The class in that jar file was writing unwanted log. I tried everything, went through so many forums.
So solution for me was to set ROOT to only ERROR:
In application.yml
logging:
level:
ROOT: ERROR
com.mypackage: INFO
org.springframework.*: INFO
So, this way only errors will be shown in the log but also info logs that you have configured.
I'm putting here some codes I've tried didn't work for me but may work for someone else:
In application.yml
,
I tried this:
logging:
level:
com.organization.package: OFF
I tried this:
logging:
level:
com.organization.package.*: OFF
I tried this:
ClassThatLogsUnwanted class = new ClassThatLogsUnwanted();
Logger.getLogger(class.getName()).setLevel(Level.OFF);
Upvotes: 0
Reputation: 21315
The problem with your approach is that it only configures the root level logger; individual logs will be turned back on if the matching logger properties are set (e.g. logging.level.org.springframework.boot=DEBUG
). I'm guessing that's why your self answer needed to explicitly disable the org.springframework.boot
logger as well as the root logger.
One approach to completely disable logging would be to create a special logback.xml
file that disables logging completely.
<configuration>
</configuration>
If you always want logging turned off, you can just create the logback.xml
file and put it in the root package (e.g. src/main/resources/logback.xml
). If you only want it disabled in certain scenarios (e.g. if in a "nologging" Spring profile), you could create a custom file with a different name (logback-off.xml
) and specify that as the config file for the profiles/cases where you want it disabled.
logging.config=classpath:logback-off.xml
Upvotes: 0
Reputation: 3849
To answer my own question: after trial and error, I finally ended up with the following which suppresses all output on startup via the application.properties
file:
logging.level.root=OFF
logging.level.org.springframework.boot=OFF
spring.main.banner-mode=OFF
Upvotes: 24
Reputation: 4495
Add the following to the the package of your choice.
logging.level.<package>=OFF
logging.level.root=OFF
doesn´t work for me
Upvotes: 4