How to create daily storagenode logs

with the V2 network logs were created every twenty four period and closed and saved and a new one would be created automatically I would like to be able to do exactly that with V3.

exports a log file from docker.

docker logs storagenode >& /zPool/storj_etc/storj_logs/2020-04-24_storagenode.log

and this gives you a live log you can follow…
docker logs storagenode --tail 20 --follow

i really should find out how to reset the logs, basically thats all one needs…
Export last 24hour period log to a logfile with date in its name. maybe nodename depending on how much one want to make run automatic.

and then one simply clears the log… and repeat after 24 hours… but i haven’t found a command to clear the logs, i bet its out there… but alas … i can look for it tomorrow… please post it if you figure it out… there are also other methods… ofc

but this doesn’t make your storagenode deviate from default… which is why i like it… it can be kept a completely separate system, and thus can simply be moved with any export or given to anyone else later… hell it even works on docker on windows i would assume xD

thanks but this will not automate the process which is what I’m looking to achieve

it’s a command, you simply ask your OS either windows or Linux to run it daily…

i will assume you are running windows, then you will just need to use task schedule… with that you can run whatever you like in whatever sequence you like… and you just simp,ly put in the command with a variable output for system time / date or whatever… the most basic of scripting or command lines really…

so yeah thats exactly what it will do… else you can use logrotate on linux… but then you will need to move your log location in your docker storagenode run command to direct it outside the container…
which leads to other handicaps down the line…

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.

7 Likes