Network Logging (Ktor)
Set up network logging with Ktor in your Kotlin Multiplatform app using Luciq. Capture HTTP requests and responses made via Ktor for better debugging.
The Luciq KMP library provides automatic network logging for Ktor HttpClient: it intercepts requests and responses, injects W3C trace headers for distributed tracing, and sends logs to the native Luciq SDK for bug reports and APMKmp.
Install the plugin
Add the plugin to your HttpClient:
import ai.luciq.kmp.interceptors.LuciqKtorPlugin
val client = HttpClient(Engine) {
install(LuciqKtorPlugin)
}All requests made with this client are logged (URL, method, headers, body, timing, status). The plugin also injects a W3C traceparent header when the native SDK supports it.
How it works
Request: The plugin captures URL, method, headers, and body, and may add a
traceparentheader.Response: It captures status, headers, and body, computes duration, and sends a
NetworkDatarecord to the native SDK viaNetworkLoggerKmp.networkLog.Errors: Failed requests are logged with error domain and message.
Body size may be truncated by the native SDK. Obfuscation and omission callbacks (see Obfuscation & Omission) are applied before sending to the native SDK.
Manual logging
If you use another HTTP client, build a NetworkData instance and call:
You can get a W3C header for your request with:
Body and auto-masking
Obfuscation & Omission – Remove or mask sensitive data and skip certain requests
Last updated