Kotlin multiplatform HTTP client logging plugin for LinuxX64 target that provides comprehensive request and response logging capabilities.
—
Control what information gets logged with granular level settings, from basic request info to complete request/response bodies.
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
}
}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: BooleanUsage 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
}Logs complete request and response information including body content.
What gets logged:
Use cases:
Logs request/response info and headers but skips body content.
What gets logged:
Use cases:
Logs request/response info and body content but skips headers.
What gets logged:
Use cases:
Logs only basic request/response information.
What gets logged:
Use cases:
Disables all logging output.
What gets logged:
Use cases:
Install with Tessl CLI
npx tessl i tessl/maven-io-ktor--ktor-client-logging-linuxx64