1

I tried this tutorial and enabled via logging.level ... = TRACE in yml. But there are no logs for response, only for requests body and headers. I looked in the apache code and didn't see the way where responses logs, only requests.

Is there a way to log apache httpClient responses via configs? Could they be enabled only by yml and be readable?

Thank you, Irina

2
  • Do u have a github project with you? Commented Aug 5, 2019 at 12:11
  • log4j.logger.httpclient.wire=DEBUG seems to be working. Please post your yml if it does not work. Commented Aug 5, 2019 at 23:20

1 Answer 1

2

for v4 of the apache http components library, you need to set the org.apache.http.wire logger to DEBUG level as per the apache http v4 wiki:

Depending on which logging framework you are using, that could be done like:

Apache Commons Logging (set the system properties):

-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
-Dorg.apache.commons.logging.simplelog.showdatetime=true
-Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG

Log4j (in log4j.properties):

log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n 

log4j.logger.org.apache.http=DEBUG

Logback (in Code):

((ch.qos.logback.classic.Logger) LoggerFactory.getLogger("org.apache.http.wire")).setLevel(Level.DEBUG);

Logback (in logback.xml config file):

<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>
    <root level="info">
        <appender-ref ref="STDOUT" />
    </root>
    <logger name="org.apache.http.wire" level="DEBUG"/>   
</configuration>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.