Reduce logfile size/auto-truncate/something

I just moved my StorjDB to a new iSCSI slice and wanted to check on the health/status/make sure it was swimming well and I can’t…

The 5+GB logfile has got to stop, Storj needs to auto-truncate/archive/rotate the log every X months whenever it’s too large to open in any text editor

1 Like

It’d be handy to have an option for doing so automatically I agree.
This said, you can setup logrotate on your side: it is quite simple.

For instance (tested on a Raspberry Pi 4B):
Add this file…

sudo nano /etc/logrotate.d/storage_nodes

… with following content (adjust as needed!):

/home/pi/storj/mounts/disk_1/storj_logs/*.log
{
        monthly
        missingok
        rotate 4
        copytruncate
        compress
        notifempty
}

The above would create a file per month, with current month readable, all older months compressed.
Logs older than 4 months would get deleted.

You may consider my write-up on using journald for logs: Logging to journald—a short story

It pushes the problem of logs to journald, and hence you can configure rotation and such there without affecting the node.

1 Like

That is a nice solution :slight_smile:
On my RPi though, because I’m using the SD card as system partition I wanted my Storj logs to go to an external mechanical drive.
You’re probably gonna tell me that journald can probably be configured so it logs to an external drive too… Never took the time to investigate that ^^’

It can ^^؜؜؜؜؜؜؜؜؜؜؜؜؜؜؜؜؜؜؜؜؜

1 Like

For docker users:

create /etc/docker/daemon.json

{
"log-driver": "json-file",
"log-opts": {
    "max-size": "1g",
    "max-file": "3"
    }
}

restart docker service.

3 Likes

You also can add those options in the docker run command

3 Likes