0

I dont know if this has occurred to anyone as yet, i have searched through and havent found any solution yet, The Log4J prints all the website content and response codes and images too..

][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.

I am using apaches's httpClient's PostMethod() and GetMethod() .. for sending data from one servlet to another servlet. I am not printing these. The log4j is printing these by itself. which i am not to understand. And the log file gets the size of around 50 to 100 MB .

My Log4j Configuration :-

<?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>

3 Answers3

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

Mudasar
  • 249
  • 1
  • 5
  • 15
0

I don't think it is log4j's fault. I think it is that the HttpClient code base is simply doing copious logging at DEBUG level. The solution would be to either change the root logger level to INFO reduce the logging ... or do this more selectively for the logger that HttpClient is using. (Unfortunately, your appender's pattern doesn't include the logger name ...)


.. but why would log4j print the image and the entire website ...

Because that is what your log4j configs are telling it to do:

  • Read the log4j introduction, particularly the parts about how to write config files.
  • Change your configs so that a different log level is used for the specific loggers that are producing those log messages.

i just commented out all the logs in one class where all unneccessary logs were printed ...

That is the wrong approach. You need to understand how log4j decides what to log and what not to log. Read the documentation. Randomly commenting stuff out won't help.

is it because i am using HttpClient 3.1 and the current version is 4.2.2 ..

No. That is not the cause.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • the log4j.xml was just too long, hence deleted the loggers with various packages and their log levels .. but why would log4j print the image and the entire website ... – Murali_dharan_raju Nov 08 '12 at 12:48
  • i just commented out all the logs in one class where all unneccessary logs were printed, even then they log4j is printing the entire website and images .. how do i handle this ? – Murali_dharan_raju Nov 08 '12 at 13:16
  • is it because i am using HttpClient 3.1 and the current version is 4.2.2 .. possible now i cannot migrate because the version 4.x is a compete rewritte of version 3.x – Murali_dharan_raju Nov 08 '12 at 14:37
0

in your log4j change DEBUG to INFO and see.

in Log4j there are level hierarchy

Loggers may be assigned levels. The set of possible levels, that is: learn here

TRACE,
DEBUG,
INFO,
WARN,
ERROR and
FATAL

When you put debug it will print DEBUG and all bellow log levels. if you put INFO it will print INFO and all bellow level logs.

Normally if you are running in production mode preper to put ERROR

Updated bellow refer this also

add this to your log4j xml and try

<logger name="httpclient.wire" additivity="false" >
  <level value="INFO" />
  <appender-ref ref="consoleAppender"/>
  <appender-ref ref="fileAppender"/>
  </logger>
Community
  • 1
  • 1
someone
  • 6,577
  • 7
  • 37
  • 60
  • but these logs are not present in log debug, even then they are printing .. And yes i have tried the logger levels, mentioning various packages to only debug information. – Murali_dharan_raju Nov 08 '12 at 12:43