Monitors network requests and responses, enhancing debugging and analysis of client-server interactions. Features include header sanitization, log retention, and content length management with platform-specific integrations.
To isolate KtorMonitor from release builds, use the ktor-monitor-logging-no-op variant. This ensures the monitor code is not included in production artifact.
- sanitize sensitive headers to avoid their values appearing in the logs
Note: Install it with addInterceptor, not addNetworkInterceptor. OkHttp does not run network interceptors for WebSocket calls, so a WebSocket handshake would not be logged. To also log WebSocket frames, open the socket with client.newMonitoredWebSocket(request, listener) instead of client.newWebSocket(...). With addInterceptor, redirects are logged as a single call.
Found a bug or have a feature request? File an issue.
🙌 Acknowledgments
Community discussions on Slack — join us in the channel.
Documentation is available at .
API is available at .
KtorMonitor is available also on JetBrains' .
KtorMonitor on .
Some parts of this project are reusing ideas that are originally coming from .
Thanks to ChuckerTeam for Chucker!
Thanks to JetBrains for Ktor and Kotlin!
Medium article:
💸 Sponsors
KtorMonitor is maintained and improved during nights, weekends and whenever team has free time. If you use KtorMonitor in your project, please consider sponsoring us.
KtorMonitor.MCP.start {
appName = "MyApp"// recommended: shows which app is which in list_apps// host = "127.0.0.1"// port = 2991// token = null
}
See MCP for the companion JAR setup and
connectivity per platform.
sanitizeHeader
filter - filter logs for calls matching a predicate.
showNotification - Keep track of latest requests and responses into notification. Default is true. Android and iOS only. Notifications permission needs to be granted.
retentionPeriod - The retention period for the logs. Default is 1h.
maxContentLength - The maximum length of the content that will be logged. After this, body will be truncated. Default is 250_000. To log the entire body use ContentLength.Full.
sanitizeHeader
filter - filter logs for calls matching a predicate.
showNotification - Keep track of latest requests and responses into notification. Default is true. Android and iOS only. Notifications permission needs to be granted.
retentionPeriod - The retention period for the logs. Default is 1h.
maxContentLength - The maximum length of the content that will be logged. After this, body will be truncated. Default is 250_000. To log the entire body use ContentLength.Full.
sanitizeHeader
filter - filter logs for calls matching a predicate.
showNotification - Keep track of latest requests and responses into notification. Default is true. Android only. Notifications permission needs to be granted.
retentionPeriod - The retention period for the logs. Default is 1h.
maxContentLength - The maximum length of the content that will be logged. After this, body will be truncated. Default is 250_000. To log the entire body use ContentLength.Full.
showNotification = true
android.permission.POST_NOTIFICATIONS
KtorMonitor
Apps can optionally use the KtorMonitor() Composable directly into own Composable code.
funmain() = application {
var showKtorMonitor by rememberSaveable { mutableStateOf(false) }
KtorMonitorWindow(
onCloseRequest = { showKtorMonitor = false },
show = showKtorMonitor
)
}
Use KtorMonitorWindow Composable with KtorMonitorMenuItem
funmain() = application {
var showKtorMonitor by rememberSaveable { mutableStateOf(false) }
Tray(
icon = painterResource(Res.drawable.ic_launcher),
menu = {
KtorMonitorMenuItem { showKtorMonitor = true }
}
)
KtorMonitorWindow(
show = showKtorMonitor,
onCloseRequest = { showKtorMonitor = false }
)
}
Wasm / Js
Web targets store the data with SQLite WASM and need a small Web Worker (WebWorkerSQLiteDriver does not ship one).
Copy sqlite.worker.js
into your web project (e.g. {project}/webpack-resources/sqlite.worker.js) and alias it in webpack.
The data is kept in memory, so no special HTTP headers are required.