stdout and stderr output in the application logs panel, which means any debug information you write to the console becomes immediately visible without needing a local development environment. This guide shows you how to enable structured debug logging in both discord.js and discord.py so you can diagnose connection issues, API errors, and unexpected crashes directly from your dashboard.
Debugging a discord.js Application
The discord.js library exposes two key client events for debugging:debug and error. The debug event fires continuously with internal library information — gateway heartbeats, shard status, rate-limit notices, and more. The error event fires whenever the client encounters an unhandled error at the connection level.
Register both listeners early in your bot’s startup sequence, before you call client.login():
The
debug event is very verbose — it emits dozens of messages per minute during normal operation. Use it while diagnosing a specific issue, then remove or comment out the listener before deploying to production to keep your logs readable.Debugging a discord.py Application
The discord.py library integrates with Python’s standardlogging module. By configuring a logger for the discord namespace, you gain visibility into every internal event the library processes — HTTP requests, gateway frames, heartbeats, and reconnection logic.
Add the following logging setup at the top of your main file, before creating your bot client:
log_handler=None argument passed to client.run() is important — without it, discord.py installs its own default handler and your log output may be duplicated or formatted inconsistently.
Understanding the log levels
Understanding the log levels
- DEBUG — Every internal library event, including gateway frames and heartbeat payloads. Very verbose.
- INFO — Higher-level events such as shard connections, login success, and guild loads.
- WARNING — Non-fatal issues like rate limiting or missed heartbeats.
- ERROR — Exceptions and failures that require attention.
- CRITICAL — Fatal conditions that prevent the bot from running.
Filtering noise from discord.http
Filtering noise from discord.http
The
discord.http sub-logger generates an entry for every API call your bot makes. Setting it to INFO suppresses individual request details while still surfacing HTTP errors (4xx/5xx responses). If you need to trace a specific API call, temporarily set it to DEBUG.