2017-04-12 49 views
1

logback-spring.xmlにINFOとしてログレベルを含めるとINFO(WARN、ERROR)以外の場合でもアプリケーションは読み込まれません。コンソールアプリケーションでは、ブートは永久に停止されます。 This is the link we tried for this。すべての助けが相当です。ログとしてコンソールでSpringBootのlogback-spring.xml springprofileが動作しない

出力:

. ____   _   __ _ _ 
/\\/___'_ __ _ _(_)_ __ __ _ \ \ \ \ 
(()\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 
\\/ ___)| |_)| | | | | || (_| | )))) 
    ' |____| .__|_| |_|_| |_\__, |//// 
=========|_|==============|___/=/_/_/_/ 
:: Spring Boot ::  (v1.5.2.RELEASE) 

logback-spring.xml

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <include resource="org/springframework/boot/logging/logback/base.xml" /> 
    <appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender"> 
     <encoder> 
      <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}-%msg %n 
      </Pattern> 
     </encoder> 
     <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> 
      <level>TRACE</level> 
     </filter> 
    </appender> 

    <appender name="minuteRollingFileAppender" 
     class="ch.qos.logback.core.rolling.RollingFileAppender"> 
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
      <FileNamePattern>/usr/src/app/logs/test%d{yyyy-MM-dd_HH-mm}.log 
      </FileNamePattern> 
      <maxHistory>30</maxHistory> 
     </rollingPolicy> 

     <encoder> 
      <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{35}-%msg %n</Pattern> 
     </encoder> 
    </appender>  


    <springProfile name="dev,staging"> 
     <root> 
      <level value="INFO" /><!--ERROR not working --> 
      <appender-ref ref="minuteRollingFileAppender" /> 
      <appender-ref ref="consoleAppender" /> 
     </root> 
    </springProfile> 
</configuration> 
+0

この[リンク](http://stackoverflow.com/questions/29429073/spring-boot-logback- application.propertiesでバナー除く

and-logging-config-property)はあなたを助けるかもしれません –

+0

返信ありがとう、私はチェックします。 – sunleo

+0

あなたのアプリケーションは本当に読み込まれていないですか?私はレベルがない場合は、バナーが表示され、他のログは表示されないという正常な動作だと思います。 – Patrick

答えて

2

春ブーツバナーは、明示的に含ままたはコンソールから除外することができます。いくつかのIDEではこれを行うための設定があります。

ログレベルがINFO以外のログを持たない場合は、アプリケーション開始のバナーのみが表示されます。アプリケーションが起動しないように見えますが、ログが書き込まれていないためです。

spring.main.banner-mode=off 

又はmainで:

SpringApplication app = new SpringApplication(SpringBootConsoleApplication.class); 
app.setBannerMode(Banner.Mode.OFF); 
app.run(args); 
関連する問題