dockerdockerfilehyperledger-fabrichyperledgerdocker-logs

is it safe to delete Hyperledger fabric Orderer logs?


i see that my docker logs file is 67GB , if i truncate the docker logs file. will it effect my network ? how i am doing it is by typing

sudo su
cd /var/lib/docker/containers/b390ca8178f28de33b702053cde84e7aba033d83a29a53777d601e2b5
echo -n "" > /home/ubuntu/b390ca8178f28de33b702053cde84e7aba033d83a29a53777d601e2b5aa18472-json.log

will it affect my network ? or is it safe to truncate the log files ? i know it's silly but still asking because it's hyperledger fabric based network.


Solution

  • It is safe to truncate the logs. We have a log rotation policy for a month. I zip the previous month's logs and dump them in a folder in case they are required for review.

    I have a script which is run using a cronjob on the first day of every month.

    #!/bin/bash
    
    con=$(docker ps --format="{{.ID}}" --no-trunc)
    containers=($con)
    logdate=$(date "+%d-%b-%y-%H-%M")
    for container in "${containers[@]}"
    do
        name=$(docker inspect --format="{{.Name}}" ${container})
        sourcePath="/var/lib/docker/containers/${container}/${container}-json.log"
        destPath="/logstore/${name}-${logdate}.tar.gz"
        tar -cvzf ${destPath} ${sourcePath}
        echo "" > ${sourcePath}
    done