How to create daily storagenode logs

are you running in a NAS or Windows or Linux?

In Ubuntu I use the “logrotate” command in a cron job to create/compress log files.

First you have to make sure you have added in the “Log Location” and “Log level” fields in the “config.yaml”

Then look in the “/etc/logrotate.d/” folder, you’ll see a list of files, those are the configs used to rotate logfiles ( usually found in “/var/log/”). I just put a “storj” config file in the logrotate.d/ and it’s done automatically

To rotate my logs i use the following config file (edit it to your requirements!):

/mnt/node/node.log {

    rotate 14
    daily
    copytruncate
    compress
    missingok
    notifempty
}

Explanation:

First line is the location of the log file you wish to rotate

roatate 14 = keep the past 14 log files
daily = frequency in which to create a new log (can be : hourly, daily, weekly, monthly, yearly)
copytruncate = copy log before compressing, and empty the log file contents (used when programs can’t be start/stopped easily)
compress = compress the log file
missingok = do not throw an error of their is no log file
notifempty = do not rotate log file if it’s empty

This will rotate the log every midnight and compress and keep the past 14 days worth of logs.

Read more here:
https://www.thegeekstuff.com/2010/07/logrotate-examples/
or have a read through the logrotate man files.

11 Likes