> For the complete documentation index, see [llms.txt](https://docs.luciq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.luciq.ai/kmp/setup-luciq-for-kmp/setup-application-performance-monitoring/network.md).

# Network

Log requests and responses for APM and bug reports in your KMP app. Covers the Luciq Ktor plugin, W3C trace headers, and manual NetworkLogger calls.

Network requests and responses can be logged for APM and bug reports. The KMP library provides:

1. **Luciq Ktor plugin** – Intercepts Ktor `HttpClient` calls, injects W3C trace headers, and logs requests/responses.
2. **NetworkLogger** – Manual logging and callbacks for obfuscation and omission.

### Ktor plugin

Install the plugin on your `HttpClient` so all requests and responses are logged and W3C headers are injected:

{% code title="Kotlin" %}

```kotlin
import ai.luciq.kmp.interceptors.LuciqKtorPlugin

val client = HttpClient(engine) {
    install(LuciqKtorPlugin)
}
```

{% endcode %}

No extra code is needed for each request; the plugin handles timing, headers, and body capture (subject to size limits and obfuscation/omission callbacks).

### Manual network logging

If you are not using Ktor or need to log a request from another HTTP client, use `NetworkLoggerKmp.networkLog` with a `NetworkData` instance. Build `NetworkData` with your request/response details (URL, method, headers, body, timestamps, status, etc.). See the [Network Logging (Ktor)](https://docs.luciq.ai/kmp/setup-luciq-for-kmp/network-logging-ktor.md) section for obfuscation and omission.

### Enable/disable body and auto-masking

{% code title="Kotlin" %}

```kotlin
NetworkLoggerKmp.setNetworkLogBodyEnabled(true)
NetworkLoggerKmp.setNetworkAutoMaskingEnabled(true)
```

{% endcode %}

For full details and W3C header usage, see [Network Logging (Ktor)](https://docs.luciq.ai/kmp/setup-luciq-for-kmp/network-logging-ktor.md) and [Obfuscation & Omission](https://docs.luciq.ai/kmp/setup-luciq-for-kmp/network-logging-ktor/obfuscation-and-omission.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.luciq.ai/kmp/setup-luciq-for-kmp/setup-application-performance-monitoring/network.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
