# Logrotate Configuration Guide for Docker Services in Pangolin Stack

**URL:** <https://forum.hhf.technology/t/logrotate-configuration-guide-for-docker-services-in-pangolin-stack/446>\
**Category:** Networking\
**Tags:** tunnels, crowdsec, pangolin\
**Created:** [January 31, 2025, 5:30pm UTC](https://forum.hhf.technology/t/logrotate-configuration-guide-for-docker-services-in-pangolin-stack/446 "2025-01-31T17:30:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhf.technoloy](https://forum.hhf.technology/user_avatar/forum.hhf.technology/hhf.technoloy/32/68_2.png) [@hhf.technoloy](https://forum.hhf.technology/u/hhf.technoloy)\
**Post date:** [January 31, 2025, 5:30pm UTC](https://forum.hhf.technology/t/logrotate-configuration-guide-for-docker-services-in-pangolin-stack/446/1 "2025-01-31T17:30:00Z")

</div>

# Logrotate Configuration Guide for Docker Services

This guide provides logrotate configurations for all services identified in the docker-compose and configuration files. Place these configurations in separate files within `/etc/logrotate.d/` for proper management.

## 1. Traefik Logs

File: `/etc/logrotate.d/traefik`

```conf
/root/config/traefik/logs/*.log {
    daily
    rotate 4
    missingok
    notifempty
    compress
    dateext
    dateformat -%Y-%m-%d
    create 0644 root root
    postrotate
        docker kill --signal=USR1 $(docker ps -q -f name=traefik)
    endscript
}

```

## 2. CrowdSec Logs

File: `/etc/logrotate.d/crowdsec`

```conf
/root/config/crowdsec_logs/*.log {
    daily
    rotate 7
    missingok
    notifempty
    compress
    dateext
    dateformat -%Y-%m-%d
    create 0644 root root
    postrotate
        docker kill --signal=USR1 $(docker ps -q -f name=crowdsec)
    endscript
}

# Specific rotation for auth.log
/root/config/crowdsec_logs/auth.log {
    daily
    rotate 7
    missingok
    notifempty
    compress
    dateext
    dateformat -%Y-%m-%d
    create 0644 root root
    postrotate
        docker kill --signal=USR1 $(docker ps -q -f name=crowdsec)
    endscript
}

# Specific rotation for syslog
/root/config/crowdsec_logs/syslog {
    daily
    rotate 7
    missingok
    notifempty
    compress
    dateext
    dateformat -%Y-%m-%d
    create 0644 root root
    postrotate
        docker kill --signal=USR1 $(docker ps -q -f name=crowdsec)
    endscript
}

```

## 3. Pangolin Application Logs

File: `/etc/logrotate.d/pangolin`

```conf
/root/config/pangolin/logs/*.log {
    daily
    rotate 5
    missingok
    notifempty
    compress
    dateext
    dateformat -%Y-%m-%d
    create 0644 root root
    postrotate
        docker kill --signal=USR1 $(docker ps -q -f name=pangolin)
    endscript
}

```

## Implementation Instructions

1. Create Configuration Files:

```bash
sudo touch /etc/logrotate.d/{traefik,crowdsec,pangolin}

```

1. Set Proper Permissions:

```bash
sudo chmod 644 /etc/logrotate.d/{traefik,crowdsec,pangolin}

```

1. Test Configurations:

```bash
sudo logrotate -d /etc/logrotate.d/traefik
sudo logrotate -d /etc/logrotate.d/crowdsec
sudo logrotate -d /etc/logrotate.d/pangolin

```

## Configuration Details Explained

### Common Parameters

- `daily`: Rotate logs every day
- `rotate N`: Keep N rotated logs before deleting
- `missingok`: Don’t error if log file is missing
- `notifempty`: Don’t rotate empty log files
- `compress`: Compress rotated logs using gzip
- `dateext`: Add date extension to rotated logs
- `dateformat`: Format for the date extension
- `create`: Create new log files with specified permissions

### Service-Specific Settings

1. **Traefik** :

2. **CrowdSec** :

3. **Pangolin** :

## Monitoring and Maintenance

1. Regular Checks:

```bash
# Check logrotate status
cat /var/lib/logrotate/status

# Test configurations
logrotate -d /etc/logrotate.d/*

# Force rotation (if needed)
logrotate -f /etc/logrotate.d/*

```

1. Log File Ownership:

```bash
# Ensure proper ownership
sudo chown root:root /etc/logrotate.d/*
sudo chmod 644 /etc/logrotate.d/*

```

## Troubleshooting

1. If logs aren’t rotating:

2. If services aren’t reopening log files:

Remember to adjust rotation periods and other parameters based on:

- Available disk space
- Compliance requirements
- Log analysis needs
- Backup schedules
