LarryRuane
commented at 11:07 PM on August 20, 2019:
contributor
This PR was part of #16115 but reviewers requested that this be made into a separate PR. As explained in #16115, it's useful, maybe even crucial, for support, analysis, and debugging purposes for the configuration arguments to be present in the debug.log file, as that may be the only artifact provided to the developer or support team. That PR logs the configuration settings (command-line arguments and bitcoin.conf contents) when bitcoind starts. But sometime later, the debug log file may be "rotated" (a new debug.log file started so it doesn't grow unbounded in size) and this information would be lost unless the previous debug.log is preserved.
This PR re-logs the configuration information when the log rotates, ensuring that the current debug.log file contains this information. Reviewers had reservations about the previous approach (which you can see in #16115's discussion thread), so this PR implements this functionality in a simpler and (I believe) much better way.
fanquake added the label Utils/log/libs on Aug 20, 2019
DrahtBot
commented at 3:01 AM on August 21, 2019:
contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
#25614 (Severity-based logging, step 2 by jonatack)
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.
DrahtBot added the label Needs rebase on Aug 21, 2019
LarryRuane force-pushed on Aug 21, 2019
DrahtBot removed the label Needs rebase on Aug 21, 2019
LarryRuane force-pushed on Aug 21, 2019
in
test/functional/test_framework/test_node.py:310
in
d252dfe814outdated
def assert_debug_log(self, expected_msgs, unexpected_msgs, timeout=2):
if unexpected_msgs is None:
unexpected_msgs = []
FWIW I think we should use a linter to guard against this Python gotcha :-)
LarryRuane
commented at 3:48 AM on August 26, 2019:
Great catch, I had no idea! I fixed this in #16115 (where it was introduced) and force-pushed rebased this PR onto that branch.
LarryRuane
commented at 8:27 PM on August 29, 2019:
@practicalswift, I don't think this was an actual problem. I added a debug print and unexpected_msgs didn't include previous values. I think it's not broken because this function, assert_debug_log(), doesn't modify the variable (it's not mutable). Here's an extremely simplified version of this function and some sample calls to it:
def assert_debug_log(unexpected_msgs=[]):
print(unexpected_msgs)
for unexpected_msg in unexpected_msgs:
print(' ', unexpected_msg)
assert_debug_log()
assert_debug_log(["foo"])
assert_debug_log(unexpected_msgs=["foo"])
assert_debug_log("bar") # not actually called this way but just curious
assert_debug_log()
The output:
[]
['foo']
foo
['foo']
foo
bar
b
a
r
[]
What prompted me to investigate this further is that I wondered if any of our existing python code has this problem. I found just one instance, which is in wallet_importmulti.py:
DrahtBot added the label Needs rebase on Apr 23, 2021
LarryRuane force-pushed on Apr 24, 2021
LarryRuane
commented at 3:48 AM on April 24, 2021:
contributor
Force-pushed required rebase. I should have mentioned earlier that you can test this manually by starting bitcoind, waiting for it to start up and sync, and then running:
kill -SIGHUP `pgrep bitcoind`
Then check debug.log; the version information and configuration settings should appear at the end. (You can do that kill repeatedly, and the information will appear again each time.)
A more realistic test is is to do actual log rotation: Start bitcoind, wait for it to start up, then
mv ~/.bitcoin/debug.log ~/.bitcoin/debug.log.old
(Note that in this state, additional logging will go to debug.log.old; the new debug.log won't exist.)
Then send the signal. A new debug.log will be created containing the version and configuration information. Further logging will appear there (and not to debug.log.old). The intention is that debug.log.old can be compressed, or archived (or deleted) or whatever. (See man logrotate.)
DrahtBot removed the label Needs rebase on Apr 24, 2021
DrahtBot cross-referenced this on Jun 27, 2021 from issue Rotate debug.log file by LarryRuane
rebroad
commented at 4:46 PM on November 21, 2021:
contributor
NACK - does not seem useful or necessary (given the previous logs can be referred to easily).
LarryRuane
commented at 5:28 PM on November 21, 2021:
contributor
NACK - does not seem useful or necessary (given the previous logs can be referred to easily).
Well, if it's not useful or necessary, I don't think it's for this reason, because an external log rotation agent (see logrotate on Unix-like systems, for example) may have deleted the initial part of the debug.log file for the currently-running instance of bitcoind that contains the configuration information (which does get logged at startup).
rebroad
commented at 1:13 PM on November 25, 2021:
contributor
NACK - does not seem useful or necessary (given the previous logs can be referred to easily).
Well, if it's not useful or necessary, I don't think it's for this reason, because an external log rotation agent (see logrotate on Unix-like systems, for example) may have deleted the initial part of the debug.log file for the currently-running instance of bitcoind that contains the configuration information (which does get logged at startup).
ah, I see.. yes, in that case this might be useful, but I think it's better if it's optional - or you could just use a logrotate script to save this part of the debug.log file elsewhere before it deletes the file.
DrahtBot added the label Needs rebase on Sep 1, 2022
DrahtBot
commented at 9:18 PM on September 1, 2022:
contributor
<!--cf906140f33d8803c4a75a2196329ecb-->
🐙 This pull request conflicts with the target branch and needs rebase.
<sub>Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".</sub>
achow101
commented at 6:01 PM on October 12, 2022:
member
Closing this as it has not had any activity in a while. If you are interested in continuing work on this, please leave a comment so that it can be reopened.
achow101 closed this on Oct 12, 2022
knst referenced this in commit 4d794e027c on Feb 13, 2023
knst referenced this in commit 45d58d93ed on Feb 13, 2023
knst referenced this in commit 16ad65a17c on Feb 28, 2023
knst referenced this in commit 4507ba2728 on Feb 28, 2023
knst referenced this in commit 3c2ab6c42b on Mar 14, 2023
knst referenced this in commit 1fad1541e8 on Mar 15, 2023
PastaPastaPasta referenced this in commit a84ec5cc19 on Apr 4, 2023
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-05-19 06:54 UTC