Skip to content

Reduce log noise#34729

Open
ajtowns wants to merge 7 commits intobitcoin:masterfrom
ajtowns:202603-logerror
Open

Reduce log noise#34729
ajtowns wants to merge 7 commits intobitcoin:masterfrom
ajtowns:202603-logerror

Conversation

@ajtowns
Copy link
Contributor

@ajtowns ajtowns commented Mar 4, 2026

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.

ajtowns added 7 commits March 4, 2026 15:29
This generalises the functionality introduced for PCP/NAT-PMP logging
in bitcoin#34549.
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.
@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 4, 2026

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

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)
  • #30342 (kernel, logging: Pass Logger instances to kernel objects by ryanofsky)
  • #29700 (kernel, refactor: return error status on all fatal errors 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.

@ajtowns
Copy link
Contributor Author

ajtowns commented Mar 4, 2026

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.

Copy link
Contributor

@kevkevinpal kevkevinpal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK c665935

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

: coin->nHeight;
} else {
LogInfo("ERROR: %s: Missing input %d in transaction \'%s\'\n", __func__, i, tx.GetHash().GetHex());
LogWarning("%s: Missing input %d in transaction \'%s\'", __func__, i, tx.GetHash().GetHex());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LogWarning("%s: Missing input %d in transaction \'%s\'", __func__, i, tx.GetHash().GetHex());
LogWarning(BCLog::VALIDATION, %s: Missing input %d in transaction \'%s\'", __func__, i, tx.GetHash().GetHex());

}
if (!state.IsValid()) {
LogInfo("Block validation error: %s", state.ToString());
LogWarning("Block validation error: %s", state.ToString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LogWarning("Block validation error: %s", state.ToString());
LogWarning(BCLog::VALIDATION, "Block validation error: %s", state.ToString());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants