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
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

Ktor Client Logging

Ktor Client Logging is a multiplatform HTTP client plugin that provides comprehensive request and response logging capabilities for LinuxX64 and other targets. It offers configurable detail levels, multiple output formats, header sanitization, and platform-specific logger integrations.

Package Information

  • Package Name: ktor-client-logging-linuxx64
  • Package Type: maven
  • Language: Kotlin
  • Installation: Implementation provided as part of Ktor Client plugins
  • Coordinates: io.ktor:ktor-client-logging-linuxx64:3.2.0

Core Imports

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

For HttpClient installation:

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

Basic Usage

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

// Install logging plugin with basic configuration
val client = HttpClient {
    install(Logging) {
        level = LogLevel.HEADERS
        logger = Logger.DEFAULT
    }
}

// Or with custom configuration
val client = HttpClient {
    install(Logging) {
        level = LogLevel.ALL
        format = LoggingFormat.OkHttp
        logger = Logger.SIMPLE
        
        // Filter requests
        filter { request -> 
            request.url.host.contains("api.example.com")
        }
        
        // Sanitize sensitive headers
        sanitizeHeader { headerName -> 
            headerName == "Authorization"
        }
    }
}

Architecture

The Ktor Client Logging plugin is built around several key components:

  • Plugin Configuration: LoggingConfig class provides DSL-based configuration options
  • Logging Levels: LogLevel enum controls what information gets logged (INFO, HEADERS, BODY, ALL, NONE)
  • Output Formats: LoggingFormat enum supports Default and OkHttp-style formatting
  • Logger Interface: Abstraction supporting multiple platform-specific implementations
  • Request/Response Processing: Internal pipeline integration for transparent logging
  • Content Observation: Smart binary detection and content type handling

Capabilities

Plugin Installation and Configuration

Core plugin installation with comprehensive configuration options including levels, formats, filtering, and header sanitization.

val Logging: ClientPlugin<LoggingConfig>

fun HttpClientConfig<*>.Logging(block: LoggingConfig.() -> Unit = {})

Plugin Configuration

Logging Levels and Control

Control what information gets logged with granular level settings and request filtering capabilities.

enum class LogLevel(val info: Boolean, val headers: Boolean, val body: Boolean) {
    ALL(true, true, true),
    HEADERS(true, true, false),
    BODY(true, false, true),
    INFO(true, false, false),
    NONE(false, false, false)
}

Logging Levels and Control

Logger Implementations

Platform-specific logger implementations providing integration with system logging frameworks.

interface Logger {
    fun log(message: String)
    companion object
}

val Logger.Companion.DEFAULT: Logger
val Logger.Companion.SIMPLE: Logger  
val Logger.Companion.EMPTY: Logger

Logger Implementations

Output Formatting

Multiple output format options for compatibility with different logging tools and preferences.

enum class LoggingFormat {
    Default,
    OkHttp
}

Output Formatting

docs

configuration.md

index.md

levels-and-control.md

logger-implementations.md

output-formatting.md

tile.json