> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/observability/enable-session-logs.md).

# How to enable session logs

**Session logging** sends AI telemetry to the DNotifier dashboard for every `sendAI` call — session start, completion, token usage, and model.

Enable it with **`logs: true`** on the `DNotifier` constructor (not per request).

## Why enable logs?

* Audit which model handled a request (`gpt-4o`, project default, etc.)
* Track token usage from responses when available
* Debug failed or slow AI calls in **Dashboard → Logs**
* Operate production assistants without reading application logs alone

{% hint style="info" %}
`logs: true` is **ops telemetry**. It is not the same as saving conversation history for your product UI — that is [`saveHistory`](/product-docs/observability/save-ai-message-history.md).
{% endhint %}

## How to enable logs

{% tabs %}
{% tab title="JavaScript" %}

```js
const notifier = new DNotifier({
  appId: process.env.DNOTIFIER_APP_ID,
  secret: process.env.DNOTIFIER_SECRET,
  transport: "http",
  userId: "user-123",
  logs: true,
  onConnected: () => {},
  onMessage: () => {},
  onDisconnected: () => {},
});

await notifier.connect();

await notifier.sendAI({
  senderId: "user-123",
  provider: "open_ai",
  model: "gpt-4o",
  message: { text: "Summarize our refund policy." },
  saveHistory: true,
});
```

{% endtab %}

{% tab title="Python" %}

```python
notifier = DNotifier(
    app_id=os.environ["DNOTIFIER_APP_ID"],
    secret=os.environ["DNOTIFIER_SECRET"],
    transport="http",
    user_id="user-123",
    logs=True,
)
await notifier.connect()

await notifier.send_ai(
    sender_id="user-123",
    provider="open_ai",
    model="gpt-4o",
    message={"text": "Summarize our refund policy."},
    save_history=True,
)
```

{% endtab %}

{% tab title="Dart" %}

```dart
final notifier = DNotifier(
  appId: Platform.environment['DNOTIFIER_APP_ID']!,
  secret: Platform.environment['DNOTIFIER_SECRET']!,
  transport: 'http',
  userId: 'user-123',
  logs: true,
);
await notifier.connect();

await notifier.sendAI(
  senderId: 'user-123',
  provider: 'open_ai',
  model: 'gpt-4o',
  message: {'text': 'Summarize our refund policy.'},
  saveHistory: true,
);
```

{% endtab %}
{% endtabs %}

If `logs` is omitted or `false`, `sendAI` still works — nothing is written to dashboard Logs.

## What gets logged

| Event            | When                                                                  |
| ---------------- | --------------------------------------------------------------------- |
| Session start    | Before the AI request is sent                                         |
| Session complete | After HTTP response (or WebSocket AI reply)                           |
| Token usage      | From response usage when present                                      |
| Model            | From `sendAI` / agent `model`, else project default (`current_model`) |

## Transport notes

| Transport  | Logging behavior                                            |
| ---------- | ----------------------------------------------------------- |
| **`http`** | Start before request; complete after response (recommended) |
| **`ws`**   | Start on send; complete when AI reply (`code: 300`) arrives |

## Logs vs saveHistory vs observability

| Feature                    | Enable                              | Purpose                              |
| -------------------------- | ----------------------------------- | ------------------------------------ |
| **Session logs**           | `logs: true`                        | Dashboard ops / tokens / model       |
| **AI history**             | `saveHistory: true` on `sendAI`     | Product history via `fetchAIHistory` |
| **Workflow observability** | `observability: true` on `Workflow` | Multi-agent step graph               |

→ [Observability overview](/product-docs/observability/observability.md)

## Where to view logs

1. [app.dnotifier.com](https://app.dnotifier.com)
2. Open **Logs**
3. Find the session by time or session id from your `sendAI` call

→ [Dashboard overview](/product-docs/getting-started/dashboard-overview.md) · [Session logging reference](/product-docs/ai/session-logging.md)

## Next steps

* [Save AI message history](/product-docs/observability/save-ai-message-history.md)
* [AI workflow observability](/product-docs/observability/ai-workflow-observability.md)
* [Observability FAQ](/product-docs/observability/faq.md)
