2016-05-18 7 views
0

スプリングアプリケーションでデバッグモードを無効にする方法。私が本番環境でアプリケーションを実行すると、多くのデバッグログステートメントが提供され、Tomcatのログファイルはディスク内でより多くの領域を占有します。以下のように、ここでスプリングのデバッグログを無効にする方法

05:03:26.340 [http-bio-1880-exec-2] DEBUG o.s.s.w.a.ExceptionTranslationFilter - Chain processed normally 
05:03:26.340 [http-bio-1880-exec-2] DEBUG o.s.s.w.c.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.s.w.u.m.AntPathRequestMatcher - Checking match of request : '/myRestCall/1234'; against '/' 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.security.web.FilterChainProxy - /myRestCall/1234 at position 1 of 8 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter' 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - No HttpSession currently exists 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - No SecurityContext was available from the HttpSession: null. A new one will be created. 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.security.web.FilterChainProxy - /myRestCall/1234 at position 2 of 8 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter' 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.security.web.FilterChainProxy - /myRestCall/1234 at position 3 of 8 in additional filter chain; firing Filter: 'CustomUserNamePasswordAuthenticationFilter' 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.security.web.FilterChainProxy - /myRestCall/1234 at position 4 of 8 in additional filter chain; firing Filter: 'RequestCacheAwareFilter' 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.security.web.FilterChainProxy - /myRestCall/1234 at position 5 of 8 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter' 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.security.web.FilterChainProxy - /myRestCall/1234 at position 6 of 8 in additional filter chain; firing Filter: 'SessionManagementFilter' 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.security.web.FilterChainProxy - /myRestCall/1234 at position 7 of 8 in additional filter chain; firing Filter: 'ExceptionTranslationFilter' 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.security.web.FilterChainProxy - /myRestCall/1234 at position 8 of 8 in additional filter chain; firing Filter: 'FilterSecurityInterceptor' 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.s.w.a.i.FilterSecurityInterceptor - Public object - authentication not attempted 
05:03:30.118 [http-bio-1880-exec-2] DEBUG o.s.security.web.FilterChainProxy - /myRestCall/1234 reached end of additional filter chain; proceeding with original 

は、すべてのデバッグログを無効にする方法私のdepedency

  <!-- logging into console --> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>jcl-over-slf4j</artifactId> 
     <version>1.7.5</version> 
    </dependency> 
    <dependency> 
     <groupId>ch.qos.logback</groupId> 
     <artifactId>logback-core</artifactId> 
     <version>1.0.13</version> 
    </dependency> 
    <dependency> 
     <groupId>ch.qos.logback</groupId> 
     <artifactId>logback-classic</artifactId> 
     <version>1.0.13</version> 
    </dependency> 

    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>log4j-over-slf4j</artifactId> 
     <version>1.7.5</version>   
    </dependency> 

であると私は警告と例外ログを表示したいです。その結果に基づいて

は私がlogback.xml(SRC /メイン/リソース/設定/ logback.xml)以下のようなファイル、

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> 
    <!-- encoders are assigned the type 
     ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> 
    <encoder> 
     <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> 
    </encoder> 
    </appender> 
<logger name="org.springframework" level="ERROR"/> 
    <root level="ERROR"> 
    <appender-ref ref="STDOUT" /> 
    </root> 
</configuration> 

を作成した。しかしそれでもDEBUGは、コンソールでの印刷を記録します。どこで私は間違いをしていますか?

+1

何を試しましたか? log4j設定のように見える –

+1

あなたはlog4jをslf4jブリッジに使用しているようです。 log4j/logback/JULの実際のログフレームワークとは何ですか?あなたのログフレームワークの設定ファイルを投稿してください。 –

+0

@ekemchitsiga plsは更新された質問を参照してください。 – MMMMS

答えて

2

(通常はクラスパスで)どこか、あなたはこのアプリケーションのlogback.xmlconfigurationファイルを持って、

<root level="XXX"> 

はまた、あなたはおそらく"rotate" your log files削減する必要があることに注意してくださいする前にそれを編集し、

<logger name="org.springframework" level="WARNING"/> 

を追加ディスクの使用状況。

+0

更新された質問を確認してください。 – MMMMS

+1

ファイル**は、doc:http://logback.qos.ch/faq.html#configFileLocation –

+0

に示されているように、 'src/main/resources'に**存在する必要があります。ありがとうございました。 – MMMMS

関連する問題