0

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.

Adarsha Jha
  • 1,782
  • 2
  • 15
  • 37
  • It will not affect your system. I suggest you should resort to "Error" mode for all container so that you don't get low level log information. – Shobhit Srivastava Jul 08 '20 at 06:32

1 Answers1

1

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
Faisal
  • 403
  • 4
  • 18