On Thu, 25 Jun 2026 08:22:38 GMT, Jaikiran Pai <[email protected]> wrote:
>>> Does the logging by code in the httpserver include something to identity
>>> the instance?
>>
>> Nope, it doesn't. For tests, it doesn't matter much — since most HTTP server
>> & client tests run sequentially. While skimming through logs, you can
>> reliably guess which log belongs to which server. That said, for production
>> applications containing multiple HTTP servers, an identifier in the log
>> would be super helpful while troubleshooting. It'd even help with the
>> cognitive load in test logs. @kieran-farrell, @dfuch, do you agree?
>>
>>> I'm wondering how the log messages look when there is more than one
>>> instance in the VM.
>>
>> They get interleaved. Consider the following JTreg log snippet from a
>> `test/jdk/com/sun/net/httpserver/ClearTextServerSSL` execution:
>>
>>
>> [18:28:00.715] STARTED ClearTextServerSSL::test 'test()'
>> Jun 24, 2026 6:28:00 PM sun.net.httpserver.ServerImpl <init>
>> FINE: HttpServer created http localhost/127.0.0.1:0
>> Jun 24, 2026 6:28:00 PM sun.net.httpserver.ServerImpl createContext
>> FINE: context created: /ClearTextServerSSL/
>> Jun 24, 2026 6:28:01 PM sun.net.httpserver.ServerImpl$Exchange run
>> FINER: exchange started
>> Jun 24, 2026 6:28:01 PM sun.net.httpserver.ServerImpl$Exchange run
>> FINE: Exchange request line: GET /ClearTextServerSSL/clear HTTP/1.1
>> Jun 24, 2026 6:28:01 PM sun.net.httpserver.ExchangeImpl sendResponseHeaders
>> FINER: Sent headers: noContentToSend=true
>
> It might be better to include the channel being closed in the log message.
> Something like:
>
>
> logger.log(Level.DEBUG, "connection limit reached, closing accepted
> connection " + chan);
>
> That should provide one form of identification because it will include the
> local and remote host/port details of the connection being closed.
I wasn’t sure on what level of detail we wanted to expose, but I just noticed
that client address/port logging already exists at debug level logging in
for (HttpConnection c : toClose) {
logger.log(Level.DEBUG, "closing: no response: " + c);
since HttpConnection.toString() includes printing chan. So maybe adding chan to
the log as @jaikiran suggested would be acceptable.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31670#discussion_r3473318531