> For the complete documentation index, see [llms.txt](https://documentation.ocsinventory-ng.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.ocsinventory-ng.org/administrator-docs/server-setup/configuration/advanced/advanced-settings.md).

# Advanced settings

You may need to adjust backend settings to match your environment. The following files hold the values described below:

* `.env` for `SECRET_KEY`, `DEBUG`, and `FRONTEND_REDIRECT`
* `ocsinventory_backend/settings.py` for `LOGGING`, `MEDIA_ROOT`, and `MEDIA_URL`

Both files can be found at `/usr/share/ocsinventory-backend/` on a package install. Any changes will require a server restart to be effective:&#x20;

```bash
sudo systemctl restart uwsgi
```

### Environment variables

| Setting             | Description                                                                     | Production value                                         |
| ------------------- | ------------------------------------------------------------------------------- | -------------------------------------------------------- |
| `SECRET_KEY`        | A random value used to sign session cookies and authentication tokens.          | Unique value. Keep it secret.                            |
| `DEBUG`             | Shows detailed technical information on error pages.                            | `False`. `True` exposes internal details after an error. |
| `FRONTEND_REDIRECT` | The OCS interface URL. OCS redirects users here after they sign in through SSO. | `http://ocs.example.com:3000`. Required for SSO sign-in. |

### Logging

The backend writes these files to the `logs/` directory:

| File                 | Contents                                    |
| -------------------- | ------------------------------------------- |
| `ocs_auth.log`       | Sign-ins, including SSO events              |
| `ocs_collection.log` | Inventory data received from agents         |
| `ocs_backend.log`    | General backend activity                    |
| `ocs_django.log`     | Django framework messages                   |
| `ocs_management.log` | Scheduled and manual maintenance activities |

Each file rotates every Sunday (`when="W6"`). Two previous files are retained\
(`backupCount=2`). About three weeks of history are available.

`when` and `backupCount` are [TimedRotatingFileHandler](https://docs.python.org/3/library/logging.handlers.html#logging.handlers.TimedRotatingFileHandler) options.\
See [Django logging](https://docs.djangoproject.com/en/5.2/topics/logging/) for the `LOGGING` structure.

<details>

<summary>Logging sample</summary>

```python
LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        "verbose": {
            "format": "[{levelname}][{asctime}][{name}:{funcName}:{lineno}]: {message}",
            "style": "{",
        },
        "simple": {
            "format": "[{levelname}][{asctime}][{name}]: {message}",
            "style": "{",
        },
    },
    "handlers": {
        # [...],
        "ocs_backend": {
            "class": "logging.handlers.TimedRotatingFileHandler",
            "filename": f"{BASE_DIR}/logs/ocs_backend.log",
            "when": "W6",
            "backupCount": 2,
            "formatter": "verbose",
        },
        # [...],
    },
    # [...],
}
```

</details>

### Media files

Media settings control where OCS stores [deployment packages](/user-docs/deployment/packages-and-actions.md).

| Setting      | Description                                      | Default value                             |
| ------------ | ------------------------------------------------ | ----------------------------------------- |
| `MEDIA_ROOT` | Server directory where package files are stored. | `media/` under the installation directory |
| `MEDIA_URL`  | URL prefix used to serve package files.          | `/media/`                                 |

Deployment packages can be large. Ensure this directory has sufficient space.\
Include it in your backup plan with the database.


---

# 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 dynamically by asking a question.

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

```
GET https://documentation.ocsinventory-ng.org/administrator-docs/server-setup/configuration/advanced/advanced-settings.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
