---
title: "Flutter SDK: Network logs"
description: "Capture network requests to investigate bug reports with the Gleap Flutter SDK. Follow the integration code examples."
url: https://docs.gleap.ai/en/articles/551-flutter-sdk-network-logs
collection: "Flutter"
updated: 2026-11-01
language: en
---

# Flutter SDK: Network logs

Capture network requests to investigate bug reports with the Gleap Flutter SDK. Follow the integration code examples.

Gleap logs your app's network requests and attaches the most recent ones to every ticket, so you can see what went wrong.

### **Enable network logs**

Add the Gleap interceptor for your HTTP client. We support the packages [http](https://pub.dev/packages/http) and [Dio](https://pub.dev/packages/dio). Requests logged from Dart (by the interceptors or with `Gleap.logNetworkRequest`) are attached to every ticket, no dashboard setting needed.

The **Network logs** switch in the **Developer options** of your project in the [Gleap dashboard](https://app.gleap.ai) additionally turns on the native recording of `NSURLSession` requests on iOS and the JavaScript SDK's `fetch` / `XMLHttpRequest` logger on the web.

For each request Gleap logs the full URL, method, request and response headers and bodies, the status, the duration and, for failed requests, the error. Text bodies are kept up to 150 KB; binary and streaming bodies are left out. The interceptors never change a request or response, and all of them share one list of the newest 30 requests.

> **Info:** On the web, the JavaScript SDK's own logger may record the same requests when network logs are turned on, so they can show up twice.

> **Note:** Version 2.0 of both interceptors needs `gleap_sdk` 19.0.0. If you use a 1.x interceptor, update it to 2.0 together with `gleap_sdk` 19.

### **Gleap Dio Interceptor**

Add the [Gleap Dio Interceptor](https://pub.dev/packages/gleap_dio_interceptor) package to your `pubspec.yaml`. Version 2.0 needs `gleap_sdk` 19.0.0 and `dio` 5 (5.2.0 or newer).

```yaml
dependencies:
  gleap_dio_interceptor: ^2.0.0
```

Attach `GleapDioInterceptor()` after your other interceptors.

```dart
Dio dio = Dio();
dio.interceptors.add(GleapDioInterceptor());
dio.get("https://example.com");
```

### **Gleap Http Interceptor**

Add the [Gleap Http Interceptor](https://pub.dev/packages/gleap_http_interceptor) package to your `pubspec.yaml`. Version 2.0 needs `gleap_sdk` 19.0.0, [http\_interceptor](https://pub.dev/packages/http_interceptor) 3.x and Dart 3.8 / Flutter 3.32 or newer.

```yaml
dependencies:
  gleap_http_interceptor: ^2.0.0
```

Attach `GleapHttpInterceptor()` as the last interceptor.

```dart
Client client = InterceptedClient.build(interceptors: [
    GleapHttpInterceptor(),
]);
client.get(Uri.parse("https://example.com"));
```

A request is logged once your app has read its response body. Multipart request bodies are logged as a summary of their fields and file names.

> **Info:** http\_interceptor doesn't pass errors to interceptors, so requests that fail without a response (no connection, timeout) are not logged with the http interceptor. The Dio interceptor logs them with their error.

### **Other HTTP clients**

Log requests of any other client with `Gleap.logNetworkRequest`:

```dart
Gleap.logNetworkRequest(
  GleapNetworkLog(
    type: 'POST',
    url: 'https://api.example.com/orders',
    date: startedAt,
    duration: 120,
    success: true,
    request: GleapNetworkRequest(headers: {'Content-Type': 'application/json'}, payload: body),
    response: GleapNetworkResponse(status: 201, responseText: responseBody),
  ),
);
```

For a request that failed without a response, set `success: false` and `response: GleapNetworkResponse(errorText: error.toString())`.

### **Start and stop network logging**

Switch network logging off and on from your app, also against the dashboard setting:

```dart
// Stop logging new requests.
await Gleap.stopNetworkLogging();

// Log requests again.
await Gleap.startNetworkLogging();
```

After `stopNetworkLogging()`, `Gleap.logNetworkRequest` and `Gleap.attachNetworkLogs` (and with them both interceptors) ignore new requests. Requests logged before stay attached. On iOS the native recording is stopped and started as well.

> **Note:** On the web, `startNetworkLogging()` also starts the JavaScript SDK's network logger, which can't be stopped. `stopNetworkLogging()` only affects requests logged from Dart there.

## Filtering network logs

Gleap allows you to strip off specific key/value pairs from network logs. This empowers you to easily remove sensitive data like `tokens`, `passwords` or `usernames`.

### How does it work?

Open Settings → Developer → Developer options → Network logs and add keys under Ignored keys. Use Excluded domains for hosts whose requests should not be recorded. These settings load with the widget configuration and are applied on the device before a report is sent.

-   **Headers**: request and response headers with a matching name are removed (the name is matched case-insensitively).
    
-   **JSON bodies**: matching keys are removed from request and response bodies at any depth, including objects inside arrays. A key with dots, like `user.password`, also removes exactly that path.
    
-   **Form bodies and URL parameters**: matching `application/x-www-form-urlencoded` fields and query parameters are removed.
    

Independent of this list, the values of the `Authorization`, `Proxy-Authorization`, `Cookie` and `Set-Cookie` headers are always replaced by `[REDACTED]`.

> **Note:** Matching nested keys, form fields and URL parameters, and the masked credential headers, need SDK **v19.0.0** or newer. Older SDKs only remove top-level keys from headers and JSON bodies, and the Android SDK applied neither the ignored keys nor the blacklist before v19.0.0.

#### Example

To remove an API key header and every `password` field, add `x-api-key` and `password` to the list.

### Set filter with code

It's also possible to set the network log filters by code. Each call replaces the previous list. The keys set in the dashboard apply in addition.

```dart
Gleap.setNetworkLogPropsToIgnore(
    propsToIgnore: ["x-api-key", "password", "user.email"]
);
```

## Blacklisting URLs

It is possible to blacklist URLs or parts of URLs. If a network request matches one of the entries in the blacklist, the network request won't be included in the network logs.

> **Info:** Requests to Gleap's own hosts (`gleap.io` and `gleap.ai`, the domain of the [US data region](https://gleap-developer-docs.gleap.help/en/articles/711-data-regions)) are always excluded from the network logs, so you don't need to blacklist them yourself. The JavaScript SDK does this since **v18.0.0**, the iOS, Android, React Native, Flutter and Ionic Capacitor SDKs since **v19.0.0**.

To add a new entry to the blacklist, open your project in the [Gleap dashboard](https://app.gleap.ai), go to **Developer options** and add the URLs under **Network logs → Excluded domains**.

### Set blacklist with code

It's also possible to set the network log blacklist by code. Each call replaces the previous list. The domains set in the dashboard apply in addition.

```dart
Gleap.setNetworkLogsBlacklist(
    blacklist: ["analytics.example.com", "..."]
);
```

## Related

- [Flutter SDK setup](https://docs.gleap.ai/en/articles/531-flutter-sdk-setup.md)
- [Flutter SDK: User identity](https://docs.gleap.ai/en/articles/532-flutter-sdk-user-identity.md)
- [Flutter SDK: Track events](https://docs.gleap.ai/en/articles/533-flutter-sdk-track-events.md)
- [Flutter SDK: Track pages](https://docs.gleap.ai/en/articles/534-flutter-sdk-track-pages.md)
- [Flutter SDK: Frontend tools](https://docs.gleap.ai/en/articles/535-flutter-sdk-frontend-tools.md)
