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.
Last updated
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.
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.
Request: The plugin captures URL, method, headers, and body, and may add a traceparent header.
Response: It captures status, headers, and body, computes duration, and sends a NetworkData record to the native SDK via NetworkLoggerKmp.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.
If you use another HTTP client, build a NetworkData instance and call:
You can get a W3C header for your request with:
Obfuscation & Omission – Remove or mask sensitive data and skip certain requests
Last updated
scope.launch {
NetworkLoggerKmp.networkLog(networkData)
}val header = NetworkLoggerKmp.getW3CHeaderForRequest(requestHeaders, startTime)
// Attach header to your requestNetworkLoggerKmp.setNetworkLogBodyEnabled(true)
NetworkLoggerKmp.setNetworkAutoMaskingEnabled(true)