Reduce log noise #34729

pull ajtowns wants to merge 7 commits into bitcoin:master from ajtowns:202603-logerror changing 12 files +61 −53
  1. ajtowns commented at 11:56 am on March 4, 2026: contributor
    This set of changes reduces some of the exaggerated logging that was introduced in #29236 when “error()” logging was upgraded from LogPrintf (aka LogInfo) to LogError. It also introduces LogWarnThenDebug() which duplicates the behaviour of #34549 which issues a warning the first time the log line is hit, but downgrades that to categorized debug messages afterwards. This function is used for failures that are likely caused by system configuration problems (so likely degrade the node’s functionality and warrant admin attention) but are triggered by remote activity and thus could occur frequently.
  2. util/log: Add LogWarnThenDebug() helper
    This generalises the functionality introduced for PCP/NAT-PMP logging
    in #34549.
    0b75dcc7e3
  3. netbase: Reduce levels of socks5 error logging 75674718fd
  4. netbase: Tidy up logging levels
    This mostly reduces log noise by using BCLog::NET debug logging where
    possible (with `LogWarnThenDebug()` used to ensure the first log message
    still appears for things that may be due to system misconfiguration).
    Also drops some unnecessary trailing newlines.
    436bc942d3
  5. script: Lower level of oversized redeemScript log, push errors to callers c02d589667
  6. kernel/coinstats: Downgrade ComputeUTXOStates log level 1ba2b65d3f
  7. txindex: Downgrade log messages and include index name 06fea76b81
  8. validation: Upgrade log levels for possible block corruption warnings c665935d02
  9. DrahtBot commented at 11:56 am on March 4, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK kevkevinpal, ryanofsky

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34520 (refactor: Add [[nodiscard]] to functions returning bool+mutable ref by maflcko)
    • #30343 (wallet, logging: Replace WalletLogPrintf() with LogInfo() by ryanofsky)
    • #29256 (log, refactor: Allow log macros to accept context arguments by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  10. ajtowns commented at 11:59 am on March 4, 2026: contributor
    See #30348 for further background; I think the changes here should be able to stand on their own merits. I haven’t addressed cases where there’s ambiguity between LogWarning and LogError here, but if there are other current cases where things are at Warning/Error and should be Info, or at Warning/Error/Info and should be Debug, happy to add them to this PR.
  11. in src/validation.cpp:193 in c665935d02
    189@@ -190,7 +190,7 @@ std::optional<std::vector<int>> CalculatePrevHeights(
    190                               ? tip.nHeight + 1 // Assume all mempool transaction confirm in the next block.
    191                               : coin->nHeight;
    192         } else {
    193-            LogInfo("ERROR: %s: Missing input %d in transaction \'%s\'\n", __func__, i, tx.GetHash().GetHex());
    194+            LogWarning("%s: Missing input %d in transaction \'%s\'", __func__, i, tx.GetHash().GetHex());
    


    kevkevinpal commented at 2:48 pm on March 4, 2026:
    0            LogWarning(BCLog::VALIDATION, %s: Missing input %d in transaction \'%s\'", __func__, i, tx.GetHash().GetHex());
    

    ajtowns commented at 3:12 am on March 5, 2026:
    LogWarning doesn’t accept a filter category because it isn’t filterable.
  12. in src/validation.cpp:2619 in c665935d02
    2615@@ -2616,7 +2616,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
    2616         }
    2617     }
    2618     if (!state.IsValid()) {
    2619-        LogInfo("Block validation error: %s", state.ToString());
    2620+        LogWarning("Block validation error: %s", state.ToString());
    


    kevkevinpal commented at 2:48 pm on March 4, 2026:
    0        LogWarning(BCLog::VALIDATION, "Block validation error: %s", state.ToString());
    

    ajtowns commented at 3:12 am on March 5, 2026:
    LogWarning doesn’t accept a filter category because it isn’t filterable.

    kevkevinpal commented at 2:41 am on March 6, 2026:
    Ahh ya my bad. Also, it makes sense to have only debug logs to be filterable since warnings and errors should always be seen.
  13. kevkevinpal commented at 3:00 pm on March 4, 2026: contributor

    ACK c665935d02b633032147e58436e3a1c6511d64f3

    This is a good improvement on the amount of functional code dedicated to logging. Also, the LogWarnThenDebug log will be useful in future cases to help avoid log noise

    Added two comments about potentially adding BCLog::VALIDATION to the two validation logs touched

  14. in src/netbase.cpp:398 in 75674718fd
    394@@ -395,7 +395,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
    395         IntrRecvError recvr;
    396         LogDebug(BCLog::NET, "SOCKS5 connecting %s\n", strDest);
    397         if (strDest.size() > 255) {
    398-            LogError("Hostname too long\n");
    399+            LogDebug(BCLog::PROXY, "Hostname too long for SOCKS5 proxying: %s", strDest);
    


    ryanofsky commented at 5:17 pm on March 6, 2026:

    In commit “netbase: Tidy up logging levels” (436bc942d362aefbf7315c73f74d032dcb75f435)

    Maybe prefix this with Error: to indicate a problem has occurred and distinguish this from informational debug messages

    Would suggest the same for other some messages below that aren’t clearly labeled as error or failures.

  15. in src/netbase.cpp:415 in 75674718fd
    411@@ -412,40 +412,40 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
    412         sock.SendComplete(vSocks5Init, g_socks5_recv_timeout, g_socks5_interrupt);
    413         uint8_t pchRet1[2];
    414         if (InterruptibleRecv(pchRet1, 2, g_socks5_recv_timeout, sock) != IntrRecvError::OK) {
    415-            LogInfo("Socks5() connect to %s:%d failed: InterruptibleRecv() timeout or other failure\n", strDest, port);
    416+            LogDebug(BCLog::PROXY, "Socks5() connect to %s:%d failed: InterruptibleRecv() timeout or other failure", strDest, port);
    


    ryanofsky commented at 5:30 pm on March 6, 2026:

    In commit “netbase: Reduce levels of socks5 error logging” (75674718fd35102be0db288802c7dc3af57ca986)

    If this is an error communicating with the proxy server (as opposed to an error with the proxy server making a remote connection), it would seem potentially important for the user to know about so they can fix the problem with the server. Hiding this could make problems harder to diagnose, and it might be better to keep the previous level

  16. in src/netbase.cpp:558 in 436bc942d3
    555 #endif
    556 
    557     // Set the non-blocking option on the socket.
    558     if (!sock->SetNonBlocking()) {
    559-        LogInfo("Error setting socket to non-blocking: %s\n", NetworkErrorString(WSAGetLastError()));
    560+        LogWarnThenDebug(BCLog::NET, "Error setting socket to non-blocking: %s", NetworkErrorString(WSAGetLastError()));
    


    ryanofsky commented at 5:38 pm on March 6, 2026:

    In commit “netbase: Tidy up logging levels” (436bc942d362aefbf7315c73f74d032dcb75f435)

    This change seems ok, but if the goal in the commit message is to use higher levels for errors “that may be due to system misconfiguration” I don’t know why this socket error would be more likely to be the result of misconfiguration than SO_NOSIGPIPE above, or if something else account for the difference like this error being considered more severe?

  17. in src/bitcoin-tx.cpp:663 in c02d589667
    658@@ -659,7 +659,9 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
    659                 UniValue v = prevOut["redeemScript"];
    660                 std::vector<unsigned char> rsData(ParseHexUV(v, "redeemScript"));
    661                 CScript redeemScript(rsData.begin(), rsData.end());
    662-                tempKeystore.AddCScript(redeemScript);
    663+                if (!tempKeystore.AddCScript(redeemScript)) {
    664+                    throw std::runtime_error(strprintf("Error adding redeemscript=%s", HexStr(redeemScript)));
    


    ryanofsky commented at 5:48 pm on March 6, 2026:

    In commit “script: Lower level of oversized redeemScript log, push errors to callers” (c02d58966796c80a37d745957e37d5134d0c093d)

    It seems good to throw an error here though text of this message doesn’t seem ideal. Redeemscript blob is potentially large and earler logged message seems more helpful (though I’m not sure if logs are shown in bitcoin-tx so it might also be useless). Might want to add another TODO comment here to improve

  18. in src/netbase.cpp:677 in 75674718fd
    673@@ -674,7 +674,7 @@ std::unique_ptr<Sock> Proxy::Connect() const
    674 #ifdef HAVE_SOCKADDR_UN
    675     auto sock = CreateSock(AF_UNIX, SOCK_STREAM, 0);
    676     if (!sock) {
    677-        LogError("Cannot create a socket for connecting to %s\n", m_unix_socket_path);
    678+        LogWarnThenDebug(BCLog::PROXY, "Cannot create a socket for connecting to %s", m_unix_socket_path);
    


    ryanofsky commented at 7:07 pm on March 6, 2026:

    In commit “netbase: Reduce levels of socks5 error logging” (75674718fd35102be0db288802c7dc3af57ca986)

    I’m not sure LogWarnThenDebug() is the best fit here. Compared to the earlier uses in this commit and the previous one, this seems less like a persistent configuration problem and more like something that could be intermittent, e.g. due to hitting resource limits.

    In that case, warning exactly once and then may hide recurring failures. It would seem better to have a rate limit and show the error once per hour or once per day while it is still occurring, not to just show it once and never again for the lifetime of the process. Absent that, keeping this at info/warning/error level might be safer.

  19. ryanofsky approved
  20. ryanofsky commented at 8:28 pm on March 6, 2026: contributor

    Code review ACK c665935d02b633032147e58436e3a1c6511d64f3, Concept -0. Changes here seem logical overall, and I left comments the few places where I had concerns. The LogWarnThenDebug macro also seems cool and potentially useful more places.

    The thing I don’t like about this change is that it makes it harder to see if messages are errors or warnings or normal notifications. Being able to see [error] and [warning] tags is a nice feature that is unfortunate to lose. 1

    In an ideal world I would use LogWarning and LogError macros more places rather than fewer. I would also make LogWarning and LogError messages configurable and not always shown, and add a LogCritical level for truly critical messages that should always be shown even when debug logging is off.

    That said, this PR seems fine overall: some positives, some negatives, and the code changes look ok.


    1. Note that a message’s error/warning/info status is orthogonal to its priority. A message could describe a normal condition (info), an unexpected condition (warning), or a failure condition (error), and any of these messages could have high or low priority depending how important the information is, whether the condition is temporary or permanent, what side effects it could lead to, and whether it might require manual intervention. ↩︎


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-03-09 12:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me