Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable console logging in spring-boot?

I'm using the default logging configuration of spring-boot.

How can I prevent the console output, while keeping the logging into a logfile configured with logging.file=myfile.log?

My goal is to not having console windows output, but only logging to that file.

Without having to create a specific logback.xml configuration. Because I'm using spring-boot for not having to configure the logging myself.

like image 343
membersound Avatar asked May 11 '17 14:05

membersound


2 Answers

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/

like image 31
Jackson Cassimiro Avatar answered Sep 22 '22 01:09

Jackson Cassimiro


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

logging.pattern.console=

Or commenting in xml if you use it

  <!--<root level="error">-->
        <!--<appender-ref ref="console"/>-->
    <!--</root>-->
like image 85
membersound Avatar answered Sep 22 '22 01:09

membersound