Builder's Guide
  • Welcome to the Builder's Guide to the LND Galaxy!
  • The Lightning Network
    • Overview
    • Payment Channels
      • Lifecycle of a Payment Channel
      • Watchtowers
      • Understanding Sweeping
      • Etymology
    • The Gossip Network
      • Identifying Good Peers on the Lightning Network
    • Pathfinding
      • Finding routes in the Lightning Network
      • Channel Fees
      • Multipath Payments (MPP)
    • Lightning Network Invoices
      • Understanding Lightning Invoices
    • Making Payments
      • The Payment Cycle
      • Timelocks
      • ⭐Hashed Timelock Contract (HTLC)
      • Payment Etymology
      • ⭐What Makes a Good Routing Node
      • Understanding Submarine Swaps
      • Instant Submarine Swaps
    • Liquidity
      • ⭐Understanding Liquidity
      • Managing Liquidity on the Lightning Network
      • Liquidity Management for Lightning Merchants
      • How to Get Inbound Capacity on the Lightning Network
      • Lightning Service Provider
    • L402: Lightning HTTP 402 Protocol
      • Macaroons
      • L402
      • 📋Protocol Specification
      • Implementations and Links
    • Taproot Assets
      • Taproot Assets Protocol
      • Taproot Assets on Lightning
      • Edge Nodes
      • Taproot Assets Trustless Swap
      • FAQ
      • Glossary
  • Lightning Network Tools
    • LND
      • 🛠️Get Started
      • lnd.conf
      • First Steps With LND
      • Wallet Management
      • Sending Payments
      • Atomic Multi-path Payments (AMP)
      • Receiving Payments
      • Unconfirmed Bitcoin Transactions
      • Channel Fees
      • Inbound Channel Fees
      • Macaroons
      • Configuring Watchtowers
      • Pathfinding
      • Blinded Paths
      • Key Import
      • Secure Your Lightning Network Node
      • Configuration of a Routing Node
      • Quick Tor Setup
      • Configuring Tor
      • Enable ‘Neutrino mode’ in Bitcoin Core
      • Send Messages With Keysend
      • Partially Signed Bitcoin Transactions
      • Bulk onchain actions with PSBTs
      • Sweeper
      • Debugging LND
      • Fuzzing LND
      • LND API documentation
      • Channel Acceptor
      • RPC Middleware Interceptor
      • HTLC Interceptor
      • NAT Traversal
      • Recovery: Planning for Failure
      • Migrating LND
      • Disaster recovery
      • Contribute to LND
    • Lightning Terminal
      • What is Lightning Terminal?
      • 🛠️Get litd
      • Run litd
      • Integrating litd
      • Demo: Litd Speed Run
      • Connect to Terminal
      • Recommended Channels
      • Rankings
      • Health Checks
      • Liquidity Report
      • Opening Lightning Network Channels
      • Managing Channel Liquidity
      • Autofees
      • AutoOpen
      • LND Accounts
      • Loop and Lightning Terminal
      • Loop Fees
      • Pool and Lightning Terminal
      • Command Line Interface
      • Troubleshooting
      • Lightning Node Connect: Under the hood
      • LNC Node Package
      • LITD API Documentation
      • Privacy and Security
      • Privacy Policy
      • Terms of Use
    • Loop
      • 🛠️Get Started
      • The Loop CLI
      • Autoloop
      • Static Loop In Addresses
      • Instant Loop Outs
      • Peer with Loop
      • Loop API Documentation
    • Pool
      • Overview
      • Quickstart
      • 🛠️Installation
      • First Steps
      • Accounts
      • Orders and Asks
      • Sidecar Channels
      • Zero-confirmation Channels
      • Channel Leases
      • Batch Execution
      • Account Recovery
      • Pool API Documentation
      • FAQs
    • Taproot Assets
      • Get Started
      • First Steps
      • Taproot Assets Channels
      • Asset Decimal Display
      • Become an Edge Node
      • RFQ
      • Collectibles
      • Universes
      • Asset Loop
      • Debugging Tapd
      • Multisignature
      • Minting Assets With an External Signer
      • Lightning Polar
      • Operational Safety Guidelines
      • Taproot Assets API Documentation
    • Aperture
      • ⚒️Get Aperture
      • LNC Backend
      • LNC Mailbox
      • Pricing
    • Faraday
      • 🛠️Get Started
      • The Faraday CLI
      • Faraday API Documentation
  • LAPPs
    • Guides
      • Use Polar to Build Your First LAPP
        • Setup: Local Cluster with Polar
        • Setup: Run the Completed App
        • Setup: Run the App Without LND
      • Add Features
        • Feature 1: Connect to LND
        • Feature 2: Display Node Alias and Balance
        • Feature 3: Sign and Verify Posts
        • Feature 4: Modify Upvote Action
      • Make Your own LNC-powered Application
    • Next Steps
  • Community Resources
    • Resource List
    • Lightning Bulb 💡
    • Glossary
    • FAQ
Powered by GitBook
On this page
  • Overview
  • Debug Logging
  • Capturing pprof data with lnd

Was this helpful?

  1. Lightning Network Tools
  2. LND

Debugging LND

PreviousSweeperNextFuzzing LND

Last updated 6 months ago

Was this helpful?

Overview

LND ships with a few useful features for debugging, such as a built-in profiler and tunable logging levels. If you need to submit a bug report for LND, it may be helpful to capture debug logging and performance data ahead of time.

Debug Logging

Logging is useful for security and operating purposes. LND logs can typically be found on Linux at ~/.lnd/logs/bitcoin/mainnet/lnd.log, on macOS at ​​~/Library/Application Support/Lnd/logs/bitcoin/mainnet or in their specified location using the--logdir flag at startup.

By default, LND will log 10MB worth of its history, and additionally keep three blocks of logs around, compressed with gzip as lnd.log.<i>.gz in the same directory.

You can adjust the location of your log files as well their maximum size (in MB) and how many historical log files you expect LND to keep, in your file.

logdir=~/.lnd/logs maxlogfiles=3 maxlogfilesize=10 debuglevel=debug,PEER=info

Additionally, the debuglevel can be overridden and adjusted without requiring a restart using the command lncli debuglevel --level=

The available debug levels are, in order of descending detail: trace, debug, info, warn, error, critical, off

Example usage:

lncli debuglevel –-level=debug

Additionally, the log level can be adjusted for each individual subsystem. A list of the subsystem can also be obtained with the command lncli debuglevel --show

Varying debug levels for multiple subsystems can be chained together with commands.

Example usage:

debuglevel --level=BTCN=trace,LNWL=debug

Subsystems:

LNWL

lnwallet

Lightning Wallet

DISC

discovery

Discovery

NTFN

chainntnfs

Chain Notifications

CHDB

channeldb

Channel database

HSWC

htlcswitch

HTLC Switch

CMGR

connmgr

Connection Manager

BTCN

neutrino

Neutrino

CNCT

contractcourt

Contract Court

UTXN

contractcourt

Contract Court

BRAR

contractcourt

Contract Court

SPHX

sphinx

Sphinx

SWPR

sweep

Sweep Transactions

SGNR

signrpc

Signature RPC

WLKT

walletrpc

Wallet RPC

ARPC

autopilotrpc

Autopilot RPC

INVC

invoices

Invoices

NANN

netann

Network Announcements

WTWR

watchtower

Watchtower

NTFR

chainrpc

Chain RPC

IRPC

invoicesrpc

Invoices RPC

CHNF

channelnotifier

Channel Notifier

CHBU

chanbackup

Channel backup

PROM

monitoring

Monitoring

WTCL

wtclient

Watch Tower Client

PRNF

peernotifier

Peer Notifier

CHFD

chanfunding

Channel Funding

PEER

peer

Peer

CHCL

chancloser

Channel Closer

Capturing pprof data with lnd

To enable this ability, start lnd with the --profile option using a free port or add profile=9736 to your lnd.conf.

⛰  lnd --profile=9736

Now, with lnd running, you can use the pprof endpoint on port 9736 to collect runtime profiling data. You can fetch this data using curl like so:

⛰  curl http://localhost:9736/debug/pprof/goroutine?debug=1
...

CPU Profile

A CPU profile can be used to analyze LND's CPU usage. You can specify the time duration as a query parameter.

⛰ curl http://localhost:9736/debug/pprof/profile?seconds=10 > cpu.prof

Goroutine profile

The goroutine profile is very useful when analyzing deadlocks and lock contention.

⛰ curl http://localhost:9736/debug/pprof/goroutine?debug=2 > goroutine.prof

Heap profile

The heap profile is useful to analyze memory allocations.

⛰ curl http://localhost:9736/debug/pprof/heap > heap.prof

Visualizing the profile dumps

It can be hard to make sense of the profile dumps by just looking at them. The Golang ecosystem provides tools to analyze those profile dumps either via the terminal or by visualizing them. One of the tools is go tool pprof.

Assuming the profile was fetched via curl as in the examples above a nice svg visualization can be generated for the cpu profile like this:

⛰ go tool pprof -svg cpu.prof > cpu.svg

lnd has a built-in feature which allows you to capture profiling data at runtime using , a profiler for Go. The profiler has negligible performance overhead during normal operations (unless you have explicitly enabled CPU profiling).

pprof
lnd.conf
Overview
Debug Logging
Capturing pprof data with lnd