Logs & Debugging
Stream program logs in real time and inspect failed transactions with solana logs, solana confirm, and solana transaction.
Recipe
Quick-reference recipe card - copy-paste ready.
solana logs
solana logs --url devnet
solana confirm -v <SIGNATURE>
solana transaction <SIGNATURE>When to reach for this:
msg!/println!output from your program during local dev.- Diagnosing custom program errors after a failed client send.
- Watching live traffic on devnet while testing integrations.
- Correlating instruction logs with compute unit consumption.
Working Example
# Terminal 1: stream logs (localnet example)
solana config set --url http://127.0.0.1:8899
solana logs
# Terminal 2: invoke your program or transfer
solana transfer <RECIPIENT> 0.01 --allow-unfunded-recipient
# or: anchor test / curl RPC sendTransaction
# After a failed tx, inspect signature
SIG="<FAILED_SIGNATURE>"
solana confirm -v "$SIG"
solana transaction "$SIG" --output json-compact | jq '.meta.logMessages, .meta.err'What this demonstrates:
solana logssubscribes tologsSubscribeover WebSocket RPC.- Verbose confirm prints program logs and error codes inline.
- JSON transaction output preserves ordered
logMessagesfor tickets.
Deep Dive
How It Works
- Programs emit logs via
solana_program::logmacros captured in transaction meta. solana logsfilters by mentions or shows all program output depending on flags.- Failed transactions still return meta with logs up to the failure point.
- Compute budget consumption appears in meta fields on RPC responses.
Log Workflow
| Step | Command | Output |
|---|---|---|
| Stream | solana logs | Live program lines |
| Submit | app / CLI tx | Signature |
| Verify | solana confirm -v | Status + logs |
| Archive | solana transaction --output json | Full meta blob |
bash Notes
# Filter logs mentioning your program ID
solana logs | grep "<YOUR_PROGRAM_ID>"
# Include vote logs (noisy)
solana logs --include-votesGotchas
- No logs without invocation - only executed programs log. Fix: confirm your instruction actually ran (check account locks and signers).
- Log truncation - excessive
msg!hits CU and size limits. Fix: log summaries, not full account data. - Wrong RPC WebSocket URL - HTTP port ≠ WS port on some providers. Fix: use provider-documented WSS endpoint; CLI maps from config URL on standard nodes.
- Reading logs before confirm - race if you query too early. Fix: wait for
confirmedor useconfirm -vin scripts. - Vote log noise - default streams hide votes; enabling them floods output. Fix: omit
--include-votesunless debugging validators.
Alternatives
| Alternative | Use When | Don't Use When |
|---|---|---|
solana-test-validator stdout | Local Anchor tests | Remote devnet debugging |
| Explorer transaction tab | Sharing links with teammates | Automated CI capture |
simulateTransaction RPC | Pre-flight without landing | Post-mortem of landed failures |
| Surfpool / LiteSVM tests | Deterministic unit tests | Watching live mainnet traffic |
FAQs
Does solana logs work on devnet?
Yes - pass --url devnet or set config URL first. Public endpoints may rate-limit subscriptions.
Why are my msg! lines missing?
Program may not have executed (failed prior instruction), logs were truncated, or you filtered the wrong program ID.
What is a common Program failed to complete error?
Custom program error codes map to anchor_lang::error or your ProgramError variants - decode against your program's error enum.
Can I save logs to a file?
Pipe solana logs > session.log or capture logMessages from JSON transaction output.
How do I see compute units used?
solana confirm -v and transaction meta include computeUnitsConsumed on supporting RPC versions.
Do logs include CPI calls?
Yes - inner instruction logs appear indented in logMessages order.
Can I debug mainnet transactions?
Use solana transaction <SIG> against mainnet RPC - no need for solana logs unless streaming live.
How is this different from local validator output?
anchor test prints validator stdout directly; solana logs uses RPC subscriptions - same content, different transport.
Why does confirm hang?
RPC not advancing, wrong signature, or network partition. Ctrl+C and retry with a healthier endpoint.
Can I watch a specific account?
Use RPC logsSubscribe with mentions filter in client code; CLI solana logs supports mention filters per solana logs --help.
Related
- Sending SOL & Transactions - generate signatures to inspect
- Local Logs & Debugging - validator-side debugging
- WebSocket Subscriptions - underlying subscription API
- Inspecting Accounts & Programs - account state checks
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.