java 日志被 httpclient.wire.content 转储填满。我怎样才能关闭它?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2770382/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 22:44:44  来源:igfitidea点击:

Logs are filling up with httpclient.wire.content dumps. How can I turn it off?

javatomcatlog4japache-commons-httpclient

提问by Renaud

My catalina logs are filling up with gobs of statements like:

我的 catalina 日志充满了如下语句:

/logs/catalina.out:2010-05-05 02:57:19,611 [Thread-19] DEBUG httpclient.wire.content - >> "[0x4]
[0xc][0xd9][0xf4][0xa2]MA[0xed][0xc2][0x93][0x1b][0x15][0xfe],[0xe]h[0xb0][0x1f][0xff][0xd6][0xfb]
[0x8f]O[0xd4][0xc4]0[0xab][0x80][0xe8][0xe4][0xf2][\r]I&[0xaa][0xd2]BQ[0xdb](zq[0xcd]ac[0xa8]

on and on forever.

一直到永远。

I searched every config file in both tomcat and apache for the statements that purportedly turn this on as described here:

我在 tomcat 和 apache 中搜索了每个配置文件,以查找据称将其打开的语句,如下所述:

http://hc.apache.org/httpclient-3.x/logging.html

http://hc.apache.org/httpclient-3.x/logging.html

And I don't see where this logging has been enabled. No other .war I deployed does this. The log4j configuration block in the app isn't doing it.

而且我没有看到在何处启用了此日志记录。我部署的其他 .war 没有这样做。应用程序中的 log4j 配置块没有这样做。

I also tried to turn it off with statements like this:

我还尝试使用以下语句将其关闭:

org.apache.commons.httpclient.wire=SEVERE

or

或者

org.apache.commons.httpclient.wire.content=SEVERE

or

或者

httpclient.wire.content=SEVERE

in my tomcat/conf/logging.properties file, and that didn't stop it

在我的 tomcat/conf/logging.properties 文件中,这并没有阻止它

I'm using an S3 library for grails that may be the source for these. However when I run this application on my development machine (in both develop and deploy configs), I'm not seeing it.

我正在为 grails 使用 S3 库,这可能是这些库的来源。然而,当我在我的开发机器上运行这个应用程序时(在开发和部署配置中),我没有看到它。

And a related question: When would I want to use these "wire logs?"

还有一个相关的问题:我什么时候想使用这些“电线日志”?

采纳答案by ThiamTeck

Do you have any additional logging library in your Tomcat common/lib? (i.e SLF4J, Logback, Log4J, etc)

您的 Tomcat common/lib 中是否有任何其他日志记录库?(即 SLF4J、Logback、Log4J 等)

If yes, you may want to configure the respective logging configuration file as well.

如果是,您可能还需要配置相应的日志记录配置文件。

回答by Renaud

For Slf4J:

对于 Slf4J:

<dependencies>
    <!-- LOGGING -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.5.9-RC0</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>0.9.17</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.5.9-RC0</version>
    </dependency>
</dependencies>

And put logback.xml in your classpath with the content below:

并将 logback.xml 放在您的类路径中,内容如下:

<configuration>
    <!-- LOGBACK logging config file, see http://logback.qos.ch/manual/joran.html -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <!-- http://logback.qos.ch/manual/layouts.html#ClassicPatternLayout -->
            <Pattern>%-5level %msg [%logger{16} %d{HH:mm:ss}]%n</Pattern>
        </layout>
    </appender>

    <root level="debug">
        <appender-ref ref="STDOUT" />
    </root>
    <logger name="org.apache" level="WARN" />
    <logger name="org.apache.axis2" level="WARN" />
    <logger name="org.apache.axiom" level="WARN" />
    <logger name="httpclient.wire" level="WARN" />
</configuration>

回答by Ted Carroll

Here is a simple answer for Tomcat 8.5.1 - currently solved the issue on Centos. Like many, I wasted quite a bit of time on this. the httpclient has built in logging so you can't fix it with log4j or slf4j- and the answer is provided here. This applies if no other logging systems are included.

这是 Tomcat 8.5.1 的简​​单答案 - 目前已在 Centos 上解决了该问题。像许多人一样,我在这上面浪费了很多时间。httpclient 已内置日志记录,因此您无法使用 log4j 或 slf4j- 修复它,此处提供了答案。这适用于不包括其他日志系统的情况。

[http://tomcat.apache.org/tomcat-8.5-doc/logging.html][1]

[ http://tomcat.apache.org/tomcat-8.5-doc/logging.html][1]

Create a logging.properties file and place in /src/main/resources - so that it is deployed to WEB-INF/classes (the example changes the default FINE to WARN

创建一个 logging.properties 文件并放置在 /src/main/resources - 以便将其部署到 WEB-INF/classes(示例将默认 FINE 更改为 WARN

Example logging.properties for the servlet-examples web application to be placed in WEB-INF/classes inside the web application:

servlet-examples Web 应用程序的示例 logging.properties 放置在 Web 应用程序内的 WEB-INF/classes 中:

handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

org.apache.juli.FileHandler.level = WARNING
org.apache.juli.FileHandler.directory = ${catalina.base}/logs
org.apache.juli.FileHandler.prefix = ${classloader.webappName}.

java.util.logging.ConsoleHandler.level = WARNING
java.util.logging.ConsoleHandler.formatter = java.util.logging.OneLineFormatter