# Logging

The Didomi SDK on iOS will log various informational and error messages.

As recommended by Apple, we use two mechanisms for logging:

* [NSLog](https://developer.apple.com/documentation/foundation/1395275-nslog) for iOS 9
* [os\_log](https://developer.apple.com/documentation/os/logging) for iOS 10+

## Formats

### iOS 9 - NSLog

Messages logged with `NSLog` use the format: `Didomi - {LEVEL} - {Message}`

Example: `Didomi - ERROR - Didomi SDK is not ready`

### iOS 10+ - os\_log

Messages logged with `os_log` use the type type to indicate the level and the following information:

* Subsystem: `Bundle.main.bundleIdentifier` or `io.didomi.sdk` if the bundler identifier is not available
* Category: `Didomi`

Example:

![](/files/-M9VFn0OOrecoG-yvCwI)

## Levels

We use the [standard log levels supported by os\_log](https://developer.apple.com/documentation/os/oslogtype): `debug`, `error`, `info`, and `fault`.

You can decide what level of logs should be displayed by the SDK by calling the setLogLevel function:

```swift
import os

...

Didomi.shared.setLogLevel(minLevel: OSLogType.debug.rawValue)
Didomi.shared.setLogLevel(minLevel: 2)
Didomi.shared.initialize(...)
```

{% hint style="danger" %}
Make sure that the call to `setLogLevel` is done before the call to `initialize` or some messages will be logged at the wrong level.
{% endhint %}

If your app supports iOS 9, use the actual value of the error level instead of `OSLogType`:

| Level   | Value |
| ------- | ----- |
| `info`  | 1     |
| `debug` | 2     |
| `error` | 16    |
| `fault` | 17    |


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.didomi.io/cmp/mobile-sdk/ios/logging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
