0

我不知道这是否发生在任何人身上,我已经搜索过了,还没有找到任何解决方案,Log4J 也会打印所有网站内容和响应代码和图像..

][0xaf][0xac]aSn[0xbc][0xe4][0x85][0xbf]i[0x1]p[0xad][0x82])O[0xbb]"[0xd7]u[0x1a][0xcc]Q[0x87][0x98][0xeb][0xcb]+[0xf9][0x1e][0xa5][0xfd][0x83]l[0xb7][0xd6][0xb2][0xb4]RL2[0xe][0xc3]}[0xc][0xff]][0xf5][0xe3][0xad][0xda][0x83]a[0x91][\r]g[0x9a][0x9b][0xe6][0xeb][0xb7][0x80][0x8b][0xfb][0x12]:[0x14]3C[0xad][0xe5]JNN[0xc0][0xd3][0xb6]%[0xe1]_[0xd0]z([0xa4]K[0x90][0xcd][0xd8][0xcb][0xdb][0xfe][0xcc][0xf0][0x17][0xb0][0xab]f[0x7][0xc5][0x84][0xb6]=[0x91]6[0xc1]=r[0x86][0xc3]}^D4<[0xa0][0x8a][0x6]>[0xed][0xa7][0xa4][0xec]1[0x4][0x9b][0xdc][0xa5]Y*[0xa3][0xaa][0x13][0x9f]R[0x9e][\r][0x81][0xb0][0x99][0xcd]J[0xf8][0x12][0x88][0xfa]o[0x96][0xdd][0x92][\r][0xd0][0xbd][0xb8]du[0xa3]>[0xf5][0xe2][0xaa][0xb][0xd3][0xd1][0xad]0[0xf6]6[0xef]s[0x8b][0xcf][0xd0][0xd0][0xa8](0[0xa5]x[0x9]V[0x13][0xcb][0x1]<[0x83c[0xf1]A[0xfa]f[0xfa][0x97]SM[0xf3][0xc][0x91][0xe8][0x96][0x16]i[0xbf]"b[0xab][0x95]l[0x11]e[0xbd]_[0xe8] [0xe9][0xb0]A''[0xc7][0x9e][0x81][0xa7]"*[0x0]a[0xb][0xac]R[0x9f]x[0xcc][0x1c][0xc9][0xc0][0xcf][0xd8]J[0x19][0xa3]>e[0xde][0x99][0xcf]T[0xc2]{r[0xc5][0x84]r*[0xa4]8[0xe]"
2012-11-08 11:23:40,728 DEBUG - >> "[\r][\n]"
2012-11-08 11:23:40,728 DEBUG - >> "--"
2012-11-08 11:23:40,728 DEBUG - >> "Rn8Y3anzO4BsiuQ8eSDsFYPH8Yef21FYHm"
2012-11-08 11:23:40,728 DEBUG - >> "[\r][\n]"
2012-11-08 11:23:40,728 DEBUG - >> "Content-Disposition: form-data; name="
2012-11-08 11:23:40,728 DEBUG - >> """
2012-11-08 11:23:40,728 DEBUG - >> "description"
2012-11-08 11:23:40,728 DEBUG - >> """
2012-11-08 11:23:40,728 DEBUG - >> "[\r][\n]"

2012-11-08 11:23:40,728 DEBUG - >> "Rn8Y3anzO4BsiuQ8eSDsFYPH8Yef21FYHm"
    2012-11-08 11:23:40,728 DEBUG - >> "--"
    2012-11-08 11:23:40,728 DEBUG - >> "[\r][\n]"
    2012-11-08 11:23:40,728 DEBUG - Request body sent
    2012-11-08 11:23:41,481 DEBUG - << "HTTP/1.1 200 OK[\r][\n]"
    2012-11-08 11:23:41,481 DEBUG - << "HTTP/1.1 200 OK[\r][\n]"
    2012-11-08 11:23:41,481 DEBUG - << "Server: Apache-Coyote/1.1[\r][\n]"
    2012-11-08 11:23:41,481 DEBUG - << "Content-Type: text/html;charset=UTF-8[\r][\n]"
    2012-11-08 11:23:41,481 DEBUG - << "Transfer-Encoding: chunked[\r][\n]"
    2012-11-08 11:23:41,481 DEBUG - << "Date: Thu, 08 Nov 2012 11:14:44 GMT[\r][\n]"
    2012-11-08 11:23:41,481 DEBUG - << "[\r][\n]"
    2012-11-08 11:23:41,481 DEBUG - Completed Getting Page
    2012-11-08 11:23:41,481 DEBUG - << "5"
    2012-11-08 11:23:41,481 DEBUG - << "0"
    2012-11-08 11:23:41,481 DEBUG - << "[\r]"
    2012-11-08 11:23:41,481 DEBUG - << "[\n]"
    2012-11-08 11:23:41,481 DEBUG - << "{"status":"OK","code":"unspecified","message":"successfully uploaded procedure"}"
    2012-11-08 11:23:41,481 DEBUG - << "[\r]"
    2012-11-08 11:23:41,481 DEBUG - << "[\n]"
    2012-11-08 11:23:41,481 DEBUG - << "0"
    2012-11-08 11:23:41,481 DEBUG - << "[\r]"
    2012-11-08 11:23:41,481 DEBUG - << "[\n]"
    2012-11-08 11:23:41,481 DEBUG - << "[\r]"
    2012-11-08 11:23:41,481 DEBUG - << "[\n]"
    2012-11-08 11:23:41,481 DEBUG - << "[\r][\n]"
    2012-11-08 11:23:41,481 DEBUG - Resorting to protocol version default close connection policy
    2012-11-08 11:23:41,482 DEBUG - Should NOT close connection, using HTTP/1.1
    2012-11-08 11:23:41,482 DEBUG - Releasing connection back to connection manager.

我正在使用 apaches 的 httpClient 的 PostMethod() 和 GetMethod() .. 将数据从一个 servlet 发送到另一个 servlet。 我不打印这些。log4j 自己打印这些。我不明白。日志文件的大小约为 50 到 100 MB。

我的 Log4j 配置:-

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

   <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
      <param name="Threshold" value="INFO" />
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d %-5p  [%c{1}] %m %n" />
      </layout>
   </appender>
   <appender name="DRFA" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value="/home/server/webSpecimen.log" />
    <param name="DatePattern" value="'.'yyyy-MM-dd" />
    <param name="Append" value="true" />
    <param name="Threshold" value="DEBUG" />

        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p - %m%n" />
        </layout>
    </appender>

   <root>
                <level value="DEBUG" />
                <appender-ref ref="DRFA" />
        </root>

</log4j:configuration>
4

3 回答 3

0

this may help you http://en.wikipedia.org/wiki/Log4j

as I saw you have set it to debug level try to put it on INFO, WARN or ERROR level. for further details please read above link.

Thanks

于 2012-11-08T11:57:05.607 回答
0

我不认为这是 log4j 的错。我认为HttpClient代码库只是在 DEBUG 级别进行大量日志记录。解决方案是将根记录器级别更改为 INFO 减少日志记录......或者为 HttpClient 正在使用的记录器更有选择性地执行此操作。(不幸的是,您的附加程序模式不包括记录器名称......)


.. 但是为什么 log4j 会打印图像和整个网站...

因为这就是您的 log4j 配置告诉它要做的事情:

  • 阅读log4j 介绍,特别是关于如何编写配置文件的部分。
  • 更改您的配置,以便为生成这些日志消息的特定记录器使用不同的日志级别。

我刚刚注释掉了一个类中的所有日志,其中打印了所有不必要的日志......

那是错误的做法。您需要了解 log4j 如何决定记录哪些内容和不记录哪些内容。阅读文档。随意评论内容无济于事。

是不是因为我使用的是 HttpClient 3.1 而当前版本是 4.2.2 ..

不,这不是原因。

于 2012-11-08T12:07:32.910 回答
0

在您的 log4j 中将 DEBUG 更改为 INFO 并查看。

在 Log4j 中有层次结构

记录器可能被分配级别。可能级别的集合,即:learn here

TRACE,
DEBUG,
INFO,
WARN,
ERROR and
FATAL

当您进行调试时,它将打印 DEBUG 和所有以下日志级别。如果您输入 INFO,它将打印 INFO 和所有波纹管级别的日志。

通常,如果您在生产模式下运行,请准备好放置 ERROR

更新的下面也参考这个

将此添加到您的 log4j xml 并尝试

<logger name="httpclient.wire" additivity="false" >
  <level value="INFO" />
  <appender-ref ref="consoleAppender"/>
  <appender-ref ref="fileAppender"/>
  </logger>
于 2012-11-08T12:09:15.867 回答