Ethereum: Debug log for RPC access log
Turning on the debugging journal of access to RPC in Ethereum
As a programmer working with Ethereum, it is necessary to track RPC access diaries (Call Procedure Call) to debug and solve problems on the web. In this article, he will lead you by including the debugging of RPC access in the Bitcoin spinal portfolio.
Why is debugging necessary?
RPC access logs provide valuable information on the interaction with the Ethereum network, including names, callers and parameters. By analyzing these journals, you can identify potential errors, optimize performance and improve the user’s overall experience.
preliminary requirements
Before enabling the debugging of access to the RPC:
- Make sure the Bitcoin core portfolio is current.
- Install the “Bitcoind-Cli” command line interface in your system.
Turning on the debugging journal
To enable the debugup journal of access to the RPC, follow the following steps:
Step 1: Create a new file for recording debugging
Create a new file called .Debug-eth-debug.json
in the main catalog of the Bitcoin Core installation. This file will store the debugging configuration.
`Json
{
"Rpc_access_logs": {
"Format": "Json",
"Log_file": "/path/to/your/debug/logfile.json"
}
}
Replace /path/to/debug/logfile.json
to the desired location of the diary file. This will store all RPC access logs in this JSON file.
Step 2: Create a new configuration script
Create a new file called “Debug-Eth-Debug.SHin the". Debug-eth-debug "directory (created by the previous step). This script reads the debug registration configuration and writes it to the diary file.
Bash
#!/Bin/Bash
Set the location of the journal file
Log_file = "/ścieżka/to/your/debug/logfile.json"
Go to JSON configuration
While ifs = "," Read -r Command Caller Params; Down
echo "{
\ "command \": \ "$ Command \",
\ "Celller \": \ "$ caller \",
\ "Params \": [\ "$ params \"] ""
} >> $ log_file
done < /dev /null
echo "$ log_file"> debug.log
Save this script and make it to make it by launching clmod +x debug-eth-debug.sh
. Then add the following line to the coating configuration file (e.g. “~/.bashrcor ~/.zshrc
) to make a script during startup.
`Bash
Source ~/.Debug-eth-debug.sh
with the help of a debugging diary
After enabling the debugging of access to the RPC:
1
`Bash
Bitcoind -Logformat jsonrpcdebug /path/to/your/debug/logfile.json
- Open the new terminal and run:
`Bash
Bitcoind --- Logdebug /path/to/your/debug/logfile.json
This will display the debugging diary file, showing all RPC access events with their parameters.
Tips and variants
- To enable recording of specific commands or RPC interfaces (e.g. “ETH
or
WSS), add the appropriate flags to the command line argument. For example:
Bash
Bitcoind --Logformat jsonrpcdebug -interface wSS Myapp Eth '{"Method": "Getbalance", "Params": []}'
- To exclude the display of specific diaries, you can use the “-ExCLUDE” flag and then lists of names of logs or paths. For example:
`Bash
Bitcoind - -JSONRPCDEBUG JSONRPCDEBUG --INTERFACE WSS MyApp -EXCLUDE DEBUG RPCACCESS