How to disable console logging in spring-boot?

I am using spring-boot default registration configuration.

How can I prevent console output by saving logging to a log file configured with logging.file=myfile.log ?

My goal is not to display console windows, but only to register in this file.

Without the need to create a specific logback.xml' configuration. Because I'm using logback.xml' configuration. Because I'm using spring-boot`, so as not to configure the log itself.

+5
source share
3 answers

It turned out that if I set the following property to empty, console logging is disabled:

logging.pattern.console=

+7
source

I created a file called logback.xml with the content:

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

See this link for more information: https://www.mkyong.com/spring-boot/spring-boot-test-how-to-stop-debug-logs/

0
source

All supported logging systems can have logging levels set in Spring using "logging.level. * = LEVEL, where" LEVEL "is one of TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF. The root logger can be configured using logging.level.root . Example application.properties:

 logging.level.root=WARN logging.level.org.springframework.web=DEBUG logging.level.org.hibernate=ERROR 

Check this information: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html

You can also overwrite the logback configuration and set it to OFF .

 <configuration> <!-- turn OFF all logging (children can override) --> <root level="OFF"> <appender-ref ref="STDOUT" /> </root> </configuration> 

You can find additional information at the following link: https://logback.qos.ch/manual/configuration.html#rootElement

-1
source

All Articles