> 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/archive/generic/hivel-on-premises-deployment-guide-generic/9.-log-rotation-setup.md).

# 9. Log Rotation Setup

On-Prem Deployment Guide (Generic)

### Why Log Rotation?

Docker containers generate logs continuously. Without rotation, logs can fill up disk space. Hivel services are configured with automatic log rotation that creates daily log files, retains logs for 7 days, and automatically cleans up old logs.

### Setup Log Rotation

**Goal:** configure automatic daily log rotation on both servers so logs never fill the disk.

On both VM1 and VM2:

```
cd /opt/docker-onprem-installer
# Run setup script (requires sudo)
sudo ./scripts/setup-log-rotation.sh
```

This script will:

* Create log directory structure (/var/log/hivel/)
* Add a daily cron job (runs at midnight)
* Configure log rotation for all Docker containers

**Expected result:** see Verify Log Rotation Setup below.

**If it fails:** see Log rotation not working in [Troubleshooting](/archive/generic/hivel-on-premises-deployment-guide-generic/11.-troubleshooting.md).

### Verify Log Rotation Setup

```
# Check cron job is installed
sudo crontab -l

# Check log directories created
ls -la /var/log/hivel/

# Manually test rotation (optional)
sudo ./scripts/docker-log-rotate.sh

```

Expected result: sudo crontab -l lists the rotation job; ls -la /var/log/hivel/ shows a directory per service.

### Log File Locations

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

Examples:

* /var/log/hivel/auth-svc/auth-svc-2025-01-15.log
* /var/log/hivel/insightly-svc/insightly-svc-2025-01-15.log

### Viewing Logs

```
# View today's logs for a service
cat /var/log/hivel/auth-svc/auth-svc-$(date +%Y-%m-%d).log

# View logs from a specific date
cat /var/log/hivel/auth-svc/auth-svc-2025-01-15.log

# Follow logs in real-time
tail -f /var/log/hivel/auth-svc/auth-svc-$(date +%Y-%m-%d).log

# Or use Docker's logs command
docker logs -f auth-svc

```

### Log Retention

* Retention period: 7 days
* Automatic cleanup: logs older than 7 days are automatically deleted
* Daily rotation: a new log file is created every day at midnight

**Next step:** Verification and Access - confirm the deployment actually works end to end.

{% columns %}
{% column %} <a href="/archive/generic/hivel-on-premises-deployment-guide-generic/8.-deployment-methods/method-2-using-docker-compose-directly.md" class="button primary" data-icon="backward">Method 2: Using Docker Compose Directly</a>
{% endcolumn %}

{% column %}

{% endcolumn %}

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