> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/logs/integrations/providers/norbix-logging.md).

# Norbix Logging

Store your log entries in your project's own database so the Logs screen can show them.

Norbix Logging keeps your log entries in the project's default database (MongoDB) — the data stays yours, and the [Logs](/codemash/cloud/logs/logs.md) screen reads it. It is the one logging provider that delivers today, and a project can have one.

## Get your credentials

Norbix Logging needs no account and no key at a provider. It needs one thing in the project:

1. Open **Database → Integrations** and check that one database integration is the **default** (on a new managed project this is `Primary Database`). See [Database integrations](/codemash/cloud/integrations.md).
2. That is all — the integration form shows no connection fields; Norbix finds the default database when you save.

## Connect it in Cloud

**Where:** Logs → Integrations → **Add New Integration** → Norbix Logging · `/projects/<project>/logging/integrations/new/norbix-logging`

The easiest way is the check box **Save logs to my default database** when you [enable the module](/codemash/cloud/logs.md#enable-the-module) the first time — Norbix creates and tests the integration for you. Use the picker when you skipped that, or after you deleted it (the **Norbix Logging** card is shown only while the project has none).

| Field            | Required | What it does                                                                                                               | Example          |
| ---------------- | -------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| Logs storage     | —        | Text only: entries go to the project's default database integration.                                                       | —                |
| Log retention    | no       | How many days entries are kept before they are deleted automatically, a whole number from 1 to 30. Empty uses the default. | `14`             |
| Integration Name | yes      | The name in your integrations list.                                                                                        | `Norbix Logging` |

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-e390e9146674cd7dc671c8350ecc6e6a1c747195%2Fnorbix-logging-form-1.png?alt=media" alt="New Norbix Logging Integration form: Logs storage text, Log retention 14, Integration Name Norbix Logging, Cancel and Save"><figcaption><p>The filled form.</p></figcaption></figure>

Press **Save**. The page becomes **Editing Norbix Logging integration** with its `int_…` id and the badges **ENABLED** and **NOT TESTED**, and the check box for deleting stored entries appears below the test panel ([Disable or delete](/codemash/cloud/logs/integrations/disable.md)).

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-cb519858baa7520618aa105791741a1094b34dd5%2Fnorbix-logging-saved-2.png?alt=media" alt="Editing Norbix Logging integration after the test: badges ENABLED and TESTED, id int_5Xl3XCKCupADCDtrsAoluT, Log retention 14"><figcaption><p>After Save and a passed test.</p></figcaption></figure>

{% hint style="warning" %}
The form says the retention *Defaults to 7 days*, but an empty field gives **1 day**: the integration that **Save logs to my default database** creates keeps entries for one day only. Type the number of days you want (for example `14`) and press **Save**.
{% endhint %}

## Test and set as default

Press **Test integration**. Norbix runs five checks — **ResolveDatabase**, **WriteLog**, **ReadAllLogs**, **ReadLog**, **DeleteLog** — and the badge becomes **TESTED**. Test once after every **Save** from the picker: the integration receives entries only when it is enabled and its last test passed. See [Test an integration](/codemash/cloud/logs/integrations/test.md).

There is no default to set — every tested integration receives all entries ([Default integration](/codemash/cloud/logs/integrations/set-default.md)).

## Common errors

| Message                                                                                                  | Cause                                                                                       | Fix                                                                                                       |
| -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| A project can have only one Norbix Logging integration. Delete the existing one before creating another. | A second Norbix Logging from the SDK, CLI or API (Cloud hides the card).                    | Edit the existing one, or [delete it](/codemash/cloud/logs/integrations/disable.md) first.                |
| There is no active default integration (`CM-ERRORS-INTEGRATIONS-006`)                                    | The project has no default database integration.                                            | Set one under **Database → Integrations**, then save again.                                               |
| Retention must be a whole number between 1 and 30 days.                                                  | **Log retention** outside 1–30 (from code: *RetentionDays must be between 1 and 30 days.*). | Type a whole number from 1 to 30, or leave it empty.                                                      |
| Test passes, but the Logs list stays empty                                                               | The integration was disabled, or the project made no requests yet.                          | Check **Enabled** in the [list](/codemash/cloud/logs/integrations.md); use the project, then reload Logs. |

## Do it from code

```ts
const { id } = await norbix.hub.logs.saveLoggingIntegration({
  integration: {
    provider: 'NorbixLogging',
    integrationName: 'Norbix Logging',
    isEnabled: true,
    retentionDays: 14,
  } as any,
});
// a new integration receives logs only after a passed test
await norbix.hub.logs.testLoggingIntegration({ integrationId: id });
```

```sh
norbix hub logs logging integration save --integration '{"provider":"NorbixLogging","integrationName":"Norbix Logging","isEnabled":true,"retentionDays":14}'
```

`as any` is there because the TypeScript type knows only the shared fields. The client setup is on the [Logs page](/codemash/cloud/logs.md#use-it-from-code). API: [Save Logging Integration](/codemash/api-reference/logs/integrations/save-logging-integration.md) · [Test Logging Integration](/codemash/api-reference/logs/integrations/test-logging-integration.md)
