How to limit the debug.log file while running bitcoind?

7

5

the debug.log file is getting pretty big on bitcoind. how do you limit the size of the file? im on ubuntu 12

Patoshi パトシ

Posted 2013-12-16T15:44:42.217

Reputation: 8 911

Answers

6

You can use logrotate.
Create a file named bitcoin-debug in /etc/logrotate.d.

This is the contents:

/home/bitcoin/.bitcoin/debug.log
{
        rotate 5
        copytruncate
        daily
        missingok
        notifempty
        compress
        delaycompress
        sharedscripts
}

Replace /home/bitcoin/.bitcoin/debug.log with the actual path to your debug.log file.

The full logrotate manpage is here: http://manpages.ubuntu.com/manpages/jaunty/man8/logrotate.8.html

UPDATE: In ubuntu the logrotate daemon manages many different log files. In the /etc/logrotate.d folder, each file contains instructions for the logrotate deamon. Adding this file tells logrotate that you want to copy and then truncate the debug.log once a day. The other options tell it to compress the old logs after a day and to keep only 5 older logs.

I originally found out about logrotate from this thread: https://bitcointalk.org/index.php?topic=130533.0

hsmiths

Posted 2013-12-16T15:44:42.217

Reputation: 701

i dont get how this works. can you explain. thanks!Patoshi パトシ 2013-12-17T17:46:50.220

do i need to do anything to kick off the daemon, or does it automatically start doing it?tofutim 2018-04-05T20:25:02.800

logrotate runs by default in ubuntu so you don't need to do anything other than adding files to the /etc/logrotate.d folder.hsmiths 2018-05-12T18:52:07.907

7

Add -shrinkdebuglog to the options you use to start bitcoin, or add shrinkdebuglog=1 to your bitcoin.conf.

Every startup, if the log is larger than 1MB, it will shrink it to 200KB.

Nick ODell

Posted 2013-12-16T15:44:42.217

Reputation: 26 536