> For the complete documentation index, see [llms.txt](https://docs.hivel.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hivel.ai/self-managed-hivel-deployment/on-premises-generic/hivel-on-premises-deployment-guide-generic/log-rotation-setup.md).

# Log Rotation Setup

#### Run the Log Rotation Setup Script

On the host, run:

```
sudo ./scripts/setup-log-rotation.sh
```

This creates:

* Log directory: `/var/log/hivel/`
* Daily cron job at midnight to rotate logs
* 7-day retention policy for all container logs

Verify Setup

**Run:** `sudo crontab -l /`

**Success:** Output lists the log rotation job\
**Failure:** See Log rotation not working in [Troubleshooting](/self-managed-hivel-deployment/on-premises-generic/hivel-on-premises-deployment-guide-generic/troubleshooting.md).

#### Log File Locations

Logs are stored in the following pattern:

```
/var/log/hivel/<service-name>/<service-name>-YYYY-MM-DD.log
```

#### Viewing Logs

View today's logs for a service:

```
cat /var/log/hivel/auth-svc/auth-svc-$(date +%Y-%m-%d).log
tail -f /var/log/hivel/auth-svc/auth-svc-$(date +%Y-%m-%d).log
docker logs -f auth-svc
```

{% columns %}
{% column %} <a href="/self-managed-hivel-deployment/on-premises-generic/hivel-on-premises-deployment-guide-generic/deployment/method-2-docker-compose-directly.md" class="button primary" data-icon="backward">Back to Method 2 - Docker Compose Directly</a>
{% endcolumn %}

{% column %}

{% endcolumn %}

{% column %} <a href="/self-managed-hivel-deployment/on-premises-generic/hivel-on-premises-deployment-guide-generic/verification-and-access.md" class="button primary" data-icon="forward">Verification & Access</a>
{% endcolumn %}
{% endcolumns %}
