CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-io-ktor--ktor-client-logging-linuxx64

Kotlin multiplatform HTTP client logging plugin for LinuxX64 target that provides comprehensive request and response logging capabilities.

Pending
Overview
Eval results
Files

levels-and-control.mddocs/

Logging Levels and Control

Control what information gets logged with granular level settings, from basic request info to complete request/response bodies.

Capabilities

LogLevel Enum

Defines what information should be logged for HTTP requests and responses.

/**
 * Logging level enum controlling what information gets logged
 * @param info Whether to log basic request/response information
 * @param headers Whether to log request/response headers
 * @param body Whether to log request/response body content
 */
enum class LogLevel(
    val info: Boolean,
    val headers: Boolean, 
    val body: Boolean
) {
    /** Log everything: info, headers, and body content */
    ALL(true, true, true),
    
    /** Log info and headers but not body content */
    HEADERS(true, true, false),
    
    /** Log info and body but not headers */
    BODY(true, false, true),
    
    /** Log only basic request/response info */
    INFO(true, false, false),
    
    /** Disable all logging */
    NONE(false, false, false)
}

Usage Examples:

import io.ktor.client.*
import io.ktor.client.plugins.logging.*

// Log everything including request/response bodies
val client = HttpClient {
    install(Logging) {
        level = LogLevel.ALL
    }
}

// Log only headers, skip body content
val client = HttpClient {
    install(Logging) {
        level = LogLevel.HEADERS  // Default level
    }
}

// Log only basic request/response info
val client = HttpClient {
    install(Logging) {
        level = LogLevel.INFO
    }
}

// Disable logging completely
val client = HttpClient {
    install(Logging) {
        level = LogLevel.NONE
    }
}

LogLevel Properties

Each LogLevel enum value provides boolean properties indicating what should be logged.

/**
 * Whether to log basic request/response information (URL, method, status)
 */
val info: Boolean

/**
 * Whether to log request/response headers
 */
val headers: Boolean

/**
 * Whether to log request/response body content
 */
val body: Boolean

Usage Examples:

// Check what a log level includes
val level = LogLevel.HEADERS
println("Logs info: ${level.info}")       // true
println("Logs headers: ${level.headers}") // true  
println("Logs body: ${level.body}")       // false

// Conditional logging based on level capabilities
if (level.headers) {
    // Process header logging
}

if (level.body) {
    // Process body logging
}

Logging Level Details

ALL Level

Logs complete request and response information including body content.

What gets logged:

  • Request URL, method, and timing
  • Request headers (with sanitization)
  • Request body content (with binary detection)
  • Response status, timing, and headers
  • Response body content (with binary detection)

Use cases:

  • Debugging complex API interactions
  • Development and testing environments
  • Troubleshooting request/response payload issues

HEADERS Level (Default)

Logs request/response info and headers but skips body content.

What gets logged:

  • Request URL, method, and timing
  • Request headers (with sanitization)
  • Response status, timing, and headers
  • Body content is omitted

Use cases:

  • Production environments where body logging is too verbose
  • Monitoring API calls and response codes
  • Header-based debugging (authentication, content-type, etc.)

BODY Level

Logs request/response info and body content but skips headers.

What gets logged:

  • Request URL, method, and timing
  • Request body content (with binary detection)
  • Response status, timing
  • Response body content (with binary detection)
  • Headers are omitted

Use cases:

  • Payload-focused debugging
  • Content transformation verification
  • Scenarios where headers contain sensitive information

INFO Level

Logs only basic request/response information.

What gets logged:

  • Request URL and method
  • Response status and timing
  • Headers and body content are omitted

Use cases:

  • High-level request monitoring
  • Performance timing analysis
  • Minimal logging overhead in production

NONE Level

Disables all logging output.

What gets logged:

  • Nothing (plugin effectively disabled)

Use cases:

  • Production environments where logging is handled elsewhere
  • Performance-critical scenarios
  • Temporary logging disable during debugging

Install with Tessl CLI

npx tessl i tessl/maven-io-ktor--ktor-client-logging-linuxx64

docs

configuration.md

index.md

levels-and-control.md

logger-implementations.md

output-formatting.md

tile.json