0

I have a Play 2.0 app, ran play console from the command line. Somewhere in one of the libraries I use, it uses log4j and started to stream debug output for [crawler4j][1], I'm trying to figure out how to selectively disable that output in the play console. I have tried changing the following in application.conf and logger.xml without any luck

application.conf
logger.root=ERROR
logger.play=ERROR
logger.application=ERROR

logger.xml
<logger name="org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager" level="ERROR"/>

Here's a sample of the streaming debug log

13:10:18.818 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Closing connections idle longer than 60 SECONDS
13:10:18.818 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.c.t.ThreadSafeClientConnManager - Closing connections idle longer than 60 SECONDS
13:10:18.818 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Closing connections idle longer than 60 SECONDS
13:10:18.818 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.c.t.ThreadSafeClientConnManager - Closing connections idle longer than 60 SECONDS
13:10:18.818 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Closing connections idle longer than 60 SECONDS
13:10:18.818 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.c.t.ThreadSafeClientConnManager - Closing connections idle longer than 60 SECONDS
13:10:18.819 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Closing connections idle longer than 60 SECONDS
13:11:18.818 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.c.t.ThreadSafeClientConnManager - Closing connections idle longer than 60 SECONDS
13:11:18.818 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Closing connections idle longer than 60 SECONDS
13:11:18.819 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.c.t.ThreadSafeClientConnManager - Closing connections idle longer than 60 SECONDS
13:11:18.819 [java-sdk-http-connection-reaper] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Closing connections idle longer than 60 SECONDS

Just to be clear, the log settings are enforced when I ran the Play app from command line, it's when I run it from within the play console that the settings are not enforced.

4

2 に答える 2

2

ここでlog4jが実際に使用されているとは思いません。デバッグを生成するライブラリである Apache HTTP クライアントは、apache commons ロギングを介してログに記録します。

Play2 はログバック バックエンドで SLF4J API を使用します。

クラスパスに jcl-over-slf4j という名前のライブラリがあり、ログ メッセージが apache commons logging に送られ、SLF4J を介してブリッジされ、代わりにログバックされます。(私が知っているのは複雑ですが、SLF4Jが他のすべてのファサードとして機能し、そのバックエンドが「それらすべてを支配する1つのロガー」になるようにする試みです)。

play2のドキュメントでは、logger.xml でロギング設定を完全にカスタマイズできるようにする必要があることが示されているため、logger.xml ファイルが存在する場合、application.conf の設定は効果がないと思います。

logger.xml は、完全なlogback 構成ファイルである必要があります。logger.xml の内容全体を投稿したのか、変更のみを投稿したのかわかりません。

示されているような出力を抑制するには、logger.xml の内容を次のように設定できる必要があります。

<configuration>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <logger name="org.apache.http.impl.conn.tsccm" level="error" />

  <root level="debug">
    <appender-ref ref="STDOUT" />
  </root>

</configuration>

これが機能しない場合は、一番上の行を次のように変更します。

<configuration debug="true">

これにより、logback は自身を構成しようとする試みをログに記録します。これにより、より多くのポインタが得られる場合があります。

お役に立てれば。

于 2012-07-24T20:54:53.703 に答える
1

これは私のために働いた:

import org.slf4j.{Logger, LoggerFactory}

LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).asInstanceOf[
  ch.qos.logback.classic.Logger].setLevel(ch.qos.logback.classic.Level.INFO)
于 2012-11-26T00:38:18.687 に答える