CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-dev-langchain4j--langchain4j-http-client

HTTP client abstraction for LangChain4j with synchronous/asynchronous execution and Server-Sent Events (SSE) streaming support

Overview
Eval results
Files

logging-api.mddocs/api/

Logging API Reference

LoggingHttpClient Class

A decorator that wraps any HttpClient implementation to add logging functionality.

/**
 * Decorator for HttpClient that adds logging capabilities.
 * Automatically masks sensitive headers like Authorization, X-API-Key, etc.
 * Internal API - implementation details may change.
 */
public class LoggingHttpClient implements HttpClient {
    /**
     * Creates a logging HTTP client with default logger.
     *
     * @param delegateHttpClient the underlying HTTP client to wrap
     * @param logRequests whether to log HTTP requests
     * @param logResponses whether to log HTTP responses
     */
    public LoggingHttpClient(HttpClient delegateHttpClient, Boolean logRequests, Boolean logResponses);

    /**
     * Creates a logging HTTP client with custom logger.
     *
     * @param delegateHttpClient the underlying HTTP client to wrap
     * @param logRequests whether to log HTTP requests
     * @param logResponses whether to log HTTP responses
     * @param logger the SLF4J logger to use for logging
     */
    public LoggingHttpClient(HttpClient delegateHttpClient, Boolean logRequests, Boolean logResponses, Logger logger);
}

Sensitive Header Masking

The LoggingHttpClient automatically masks sensitive headers to prevent accidental logging of secrets.

Automatically Masked Headers

The following headers are automatically masked:

  • Authorization
  • X-API-Key
  • X-Auth-Token
  • Any header containing api-key (case-insensitive)

Masking Format

For headers with values of 7 or more characters:

  • First 5 characters are shown
  • Middle characters are replaced with ...
  • Last 2 characters are shown

For headers with values shorter than 7 characters:

  • Entire value is replaced with ...

Masking Examples

Original: Bearer sk-1234567890abcdef
Masked:   Beare...ef

Original: 12345
Masked:   ...

Original: api_key_abc123xyz789
Masked:   api_k...89

Logging Levels

Request and Response Logging

  • Level: INFO
  • Content: Method, URL, headers (masked), body

SSE Event Logging

  • Level: DEBUG
  • Content: Event type and data for each server-sent event

Error Logging

Errors during logging itself are caught and logged at WARN level:

WARN Exception occurred while logging HTTP request: <error message>
WARN Exception occurred while logging HTTP response: <error message>

Output Format

Request Log Format

INFO  HTTP request:
- method: POST
- url: https://api.example.com/data
- headers: [Authorization: Beare...45]
- body: {"key":"value"}

Response Log Format

INFO  HTTP response:
- status code: 200
- headers: [Content-Type: application/json]
- body: {"result":"success"}

SSE Event Log Format

DEBUG ServerSentEvent { event = null, data = "Hello" }
DEBUG ServerSentEvent { event = null, data = "world" }
DEBUG ServerSentEvent { event = "done", data = "" }

Related Documentation

  • Usage Guide: Logging Configuration Guide
  • Examples: Logging Examples

Install with Tessl CLI

npx tessl i tessl/maven-dev-langchain4j--langchain4j-http-client@1.11.0

docs

api

configuration-api.md

core-interfaces.md

logging-api.md

request-building-api.md

sse-api.md

index.md

installation.md

quick-start.md

tile.json