Scrivio Interview library
DebuggingIntermediate8 min read · updated 12 November 2026

You need to see what bytes a WebClient call sends and receives to debug a TLS or header problem in staging. How do you enable wire logging, and what are the risks?

For a WebClient on Reactor Netty, we build the HttpClient with wiretap("reactor.netty.http.client.HttpClient", LogLevel.DEBUG, AdvancedByteBufFormat.TEXTUAL) and set that logger to DEBUG; for Apache HttpClient 5 we turn on the org.apache.hc.client5.http.wire logger, for the JDK HttpClient we pass -Djdk.httpclient.HttpClient.log=headers, and for the TLS negotiation itself we add -Djavax.net.debug=ssl:handshake. The risk is that these logs contain tokens, passwords and personal data and slow every call, so we enable them only briefly, only outside production, and delete the logs afterwards.

Why this question is asked

Some bugs cannot be seen from the code at all. A partner API answers 400 only in staging, a certificate handshake fails only behind one proxy, or a header arrives in a different case than we expected. In those moments we need to see the actual bytes on the wire, not what we think we sent. Interviewers ask this question because it checks two things at once: whether we know the practical switches for each HTTP client, and whether we understand that the output of those switches is dangerous data. In this answer, we will recap what wire logging is, turn it on for Reactor Netty, Apache HttpClient 5 and the JDK client, look at the separate TLS debug output, and then go through the risks and how to contain them.

1A Quick Recap of Wire Logging

Normal application logging tells us what our code decided to do: "calling the payments API", "got status 400". Wire logging goes one level lower. It records the request line, the headers and the body exactly as the HTTP client writes them to the socket, and the response exactly as it is read back. That is the level at which header and encoding problems become visible, for example a Content-Type of text/plain where the server expects application/json, or a missing Host header added by a proxy.

TLS, the encryption layer under HTTPS, is a separate concern. When a handshake fails, there are no HTTP bytes to look at, because the connection never got that far. For those problems we need the JDK's own TLS debug output, which shows the protocol versions, cipher suites and certificates the two sides offered each other. So in practice we use two tools: wire logging for HTTP content, and TLS debug for the handshake.

2Turning On Wiretap for WebClient on Reactor Netty

WebClient does not do networking itself. It delegates to a connector, and by default in Spring Boot that is Reactor Netty. Netty has a logging handler that can be inserted into its pipeline, and Reactor Netty exposes it as wiretap(). We build our own HttpClient with wiretap enabled and hand it to WebClient through a ReactorClientHttpConnector.

Java
HttpClient httpClient = HttpClient.create()
.wiretap("reactor.netty.http.client.HttpClient", // logger category
LogLevel.DEBUG, // io.netty.handler.logging.LogLevel
AdvancedByteBufFormat.TEXTUAL); // print bytes as text, not a hex dump
WebClient client = WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(httpClient))
.build();
// application-staging.yml
// logging.level.reactor.netty.http.client.HttpClient: DEBUG

Two settings must agree. The first argument of wiretap() is the logger category, and our logging configuration must set exactly that category to DEBUG, otherwise the handler is installed but nothing is printed. TEXTUAL makes the output readable, so we see "POST /v1/charges HTTP/1.1" and each header on its own line. The default format is a hex dump, which is useful when we suspect invisible characters such as a stray byte order mark or a CR without LF.

Notice that we enable this only in a staging profile. A common mistake is to add wiretap to the shared WebClient bean and forget it there. A safer pattern is to read a property such as http.wiretap.enabled and only call wiretap() when it is true. In current versions, Reactor Netty places the logging handler so that it sees the decrypted HTTP traffic of an HTTPS call; check your version if you only see encrypted records.

If we only need headers and not raw bytes, Spring has a lighter option: spring.codec.log-request-details=true together with logging.level.org.springframework.web.reactive.function.client.ExchangeFunctions=TRACE logs the method, URL and headers at the WebClient level.

3Apache HttpClient 5 and the JDK HttpClient

If the RestClient or RestTemplate uses Apache HttpClient 5 underneath (through HttpComponentsClientHttpRequestFactory), wire logging is just a logger. HttpClient 5 writes every byte it sends and receives to the category org.apache.hc.client5.http.wire, and the headers alone to org.apache.hc.client5.http.headers.

The JDK's own java.net.http.HttpClient uses a system property instead. Its value is a list of what to log, such as errors, requests, headers, frames or ssl. The output goes through the JDK's System.Logger, which by default ends up in java.util.logging, so in a Spring Boot application we may also need the JUL-to-SLF4J bridge to see it in our usual log files.

Properties
# Apache HttpClient 5 (application-staging.properties)
logging.level.org.apache.hc.client5.http.wire=DEBUG # every byte, request and response
logging.level.org.apache.hc.client5.http.headers=DEBUG # headers only, much smaller
# JDK HttpClient (JVM option)
java -Djdk.httpclient.HttpClient.log=headers,requests -jar app.jar

So the pattern is the same for every client: find the logger or property the client library owns, turn it on for one environment, and leave application loggers alone. The headers-only option is usually enough for header bugs and produces a fraction of the volume.

4Seeing the TLS Handshake

When the error is SSLHandshakeException or "PKIX path building failed", we need to see the negotiation. The JDK's TLS implementation, JSSE, prints a detailed trace when we set javax.net.debug. The value ssl:handshake limits it to the handshake messages, which is far less noisy than all.

Shell
java -Djavax.net.debug=ssl:handshake -jar app.jar
// prints ClientHello with offered versions and cipher suites,
// ServerHello with the chosen ones, and the server's certificate chain
Step throughChoosing the right switch
  1. Did the TLS handshake fail?SSLHandshakeException, PKIX errors
    Yesjavax.net.debug=ssl:handshakeNoLook at HTTP content
  2. Do headers alone explain it?wrong Content-Type, missing auth header
    YesHeaders-only loggingNoFull wire logging, text or hex
  3. Enable in staging onlybehind a profile or property, with a time limit
  4. Reproduce, capture, switch offthen delete the captured logs

4 steps in order. Play them, or step through them one at a time.

Start with the narrowest output that can answer the question.

From this trace we can answer the usual questions. Did the server offer TLS 1.3 while our client only allows 1.2? Did the server send the full certificate chain, or only the leaf certificate, so our trust store cannot connect it to a root? Did the client send SNI, the host name extension that tells a shared server which certificate to present? But there is a catch: this output exists only when the JDK's JSSE does the TLS work. If Netty is configured to use OpenSSL through netty-tcnative, javax.net.debug shows nothing, and we use openssl s_client -connect host:443 -showcerts from the same machine instead.

5The Risks and How We Contain Them

Wire logs are dangerous because they are complete. They contain the Authorization header with a bearer token, API keys in custom headers, session cookies, client secrets in OAuth token requests, and request bodies with names, addresses and card data. Anyone who can read the log files can replay those tokens, and many log pipelines ship files to a central system that hundreds of people can search. A single afternoon of wire logging in the wrong environment can turn into a security incident and a data protection problem.

The second risk is cost. Wire logging runs on every call, formats every byte, and writes it synchronously. A service that makes 500 calls a second with 20 KB bodies would write about 10 MB of log text per second, which slows calls, fills disks and can make the logging system drop other, more useful logs.

So we treat it like a temporary instrument. We enable it in staging, never in production, through a profile or property rather than a code change, and ideally for a single client or host. We use test accounts and short-lived tokens while capturing, we keep the capture to a few minutes, and afterwards we switch it off, delete the log files and, if any real token was captured, rotate it. If a production-only problem forces us to look, we prefer headers-only logging with a redaction filter, approved by whoever owns security, for a fixed window.

6Follow-up questions

Why do I see nothing even though wiretap() is in the code?

Usually the logger level is wrong. Wiretap installs a Netty LoggingHandler that writes to the category we named, at the level we chose. If that category is still at INFO, the handler runs but every message is filtered out. Set the exact category, reactor.netty.http.client.HttpClient in our example, to DEBUG, and make sure the WebClient we call is really the one built with our customised HttpClient and not another bean.

Is it safe to use wire logging in production if we mask the Authorization header?

Only partly. Masking one header still leaves cookies, API keys in other headers, query parameters such as access_token, and bodies with personal data. Raw wire loggers do not know which bytes are sensitive, so they cannot redact reliably. In production we prefer structured logging of selected fields through an interceptor with an explicit redaction list, or metrics and traces that never contain payloads.

How would you debug a TLS problem when the client uses OpenSSL through Netty?

javax.net.debug only covers the JDK's own TLS implementation, so it prints nothing for OpenSSL. From the same host and network we run openssl s_client with -connect, -servername and -showcerts to see the chain and the negotiated protocol, and we can temporarily switch Netty to the JDK provider in staging to get the familiar JSSE trace.

7Conclusion

In this answer, we saw that wire logging is a client-specific switch: wiretap() with a matching DEBUG logger for Reactor Netty, the org.apache.hc.client5.http.wire logger for Apache HttpClient 5, and the jdk.httpclient.HttpClient.log property for the JDK client, while javax.net.debug=ssl:handshake shows the TLS negotiation that happens before any HTTP bytes. We also saw why these logs must be treated as secrets: they hold tokens and personal data, they slow every call and they grow fast, so we enable them briefly in staging, delete them afterwards and rotate anything real that they captured.

What to say in the interviewAbout 80 seconds aloud

Open with

First I would decide what I am actually debugging. If it is a handshake failure, HTTP logs will not help, so I run with -Djavax.net.debug=ssl:handshake, which shows the protocol versions, cipher suites and certificate chain each side sent, or openssl s_client if Netty uses OpenSSL.

Then, if they want more

If it is a header or body problem with WebClient, I build the Reactor Netty HttpClient with wiretap, giving it the category reactor.netty.http.client.HttpClient, LogLevel.DEBUG and AdvancedByteBufFormat.TEXTUAL, pass it in through ReactorClientHttpConnector, and set that same logger to DEBUG in the staging profile.

For Apache HttpClient 5 it is the org.apache.hc.client5.http.wire logger, or the headers logger if that is enough, and for the JDK client it is -Djdk.httpclient.HttpClient.log=headers. The important part is the risk. Wire logs contain bearer tokens, cookies, API keys and personal data in bodies, and they slow every call and produce huge files.

So I only enable them in non-production, behind a property rather than a code change, for a short window, with test credentials where possible. Afterwards I switch them off, delete the logs, and rotate any real token that was captured. In production I would rather rely on metrics, traces and redacted structured logs.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "You need to see what bytes a WebClient call sends and receives to debug a TLS or header...": https://scrivio-interview-library.netlify.app/spring-boot/http-clients/bdeff3e1ab/