Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: Belkaar on May 19, 2011, 08:53:32 PM



Title: debug.log getting bigger
Post by: Belkaar on May 19, 2011, 08:53:32 PM
Hi there,

is there a possibility to get bitcoind to not write that much (anything) to debug.log?
It gets kinda big.

Thanks


Title: Re: debug.log getting bigger
Post by: xf2_org on May 20, 2011, 12:08:27 AM

There is one pull request along those lines.



Title: Re: debug.log getting bigger
Post by: theymos on May 20, 2011, 02:00:55 AM
Bitcoin will truncate debug.log when you restart it.


Title: Re: debug.log getting bigger
Post by: Vladimir on May 22, 2011, 10:04:39 AM
I wish there was some command line option which would make bitcoind sending logs to stout or stderr instead of that stupid debug.log file.


Title: Re: debug.log getting bigger
Post by: xf2_org on May 22, 2011, 04:18:08 PM
Bitcoin will truncate debug.log when you restart it.

eh?  No, it does not truncate debug.log at startup.



Title: Re: debug.log getting bigger
Post by: xf2_org on May 22, 2011, 04:18:25 PM
I wish there was some command line option which would make bitcoind sending logs to stout or stderr instead of that stupid debug.log file.

Open an issue at github, this is a reasonable request.



Title: Re: debug.log getting bigger
Post by: theymos on May 22, 2011, 07:06:50 PM
eh?  No, it does not truncate debug.log at startup.

util.cpp:
Code:
void ShrinkDebugFile()
{
    // Scroll debug.log if it's getting too big
    string strFile = GetDataDir() + "/debug.log";
    FILE* file = fopen(strFile.c_str(), "r");
    if (file && GetFilesize(file) > 10 * 1000000)
    {
        // Restart the file with some of the end
        char pch[200000];
        fseek(file, -sizeof(pch), SEEK_END);
        int nBytes = fread(pch, 1, sizeof(pch), file);
        fclose(file);
        if (file = fopen(strFile.c_str(), "w"))
        {
            fwrite(pch, 1, nBytes, file);
            fclose(file);
        }
    }
}

init.cpp (at startup, just before writing the debug.log "header"):
Code:
    if (!fDebug && !pszSetDataDir[0])
        ShrinkDebugFile();
    printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    printf("Bitcoin version %s%s beta\n", FormatVersion(VERSION).c_str(), pszSubVer);

This feature actually annoys me, since I like to archive my debug.log. (I've disabled it on mine.)