Read Python application logs

3 min read07 November 2026

On application hosting, the panel console is your main window into the Python process. Knowing where messages go, how to structure them and how to read a traceback keeps you from debugging blind.

1. Where output goes

The panel starts your command and captures two separate streams:

  • stdout: print() and normal output.
  • stderr: warnings, errors and uncaught tracebacks.

Both show up in the console, often interleaved, and their order is not guaranteed. Another trap: when output is not a terminal, Python buffers it. Messages may arrive late, or be lost entirely if the process is killed abruptly. Set PYTHONUNBUFFERED=1 in the panel environment variables, or pass flush=True to print().

2. Structure output with logging

print() is fine for a quick test, not for a service. The logging module adds a level, a timestamp, a logger name and a configurable destination.

Python
import logging
import os
import sys

logging.basicConfig(
    level=os.environ.get("LOG_LEVEL", "INFO").upper(),
    format="%(asctime)s %(levelname)s %(name)s %(message)s",
    stream=sys.stdout,
    force=True,
)
log = logging.getLogger("app")
log.info("starting")

Keep INFO in production. Turn on DEBUG through an environment variable while investigating, then switch back: a noisy level fills the console and may expose internal data. Never log tokens, passwords or full connection strings. For an exception, log.exception("context") keeps the complete trace.

3. Read a traceback

Python prints the call stack from oldest to newest. The decisive line is the last one: exception type and message. Blocks such as During handling of the above exception or The above exception was the direct cause indicate chained exceptions; look for the deepest cause.

Lines like File "...", line N, in ... give the location, including inside dependencies. Common signatures:

  • ModuleNotFoundError: a dependency is missing from requirements.txt or failed to install.
  • SyntaxError: invalid code, the app never starts.
  • Address already in use: another process already holds the port.
  • KeyError on an environment variable: the secret is not set in the panel.

4. Restart loops

If the process exits, the panel may start it again. A short loop repeats the same error and pushes the first lines out of view. Read the beginning of the output after a restart: that is where the original cause sits. If the console truncates history, reproduce locally with python main.py and the same variables.

5. Verify and troubleshoot

  1. Restart with LOG_LEVEL=DEBUG, reproduce the issue, then set INFO again.
  2. Confirm each expected message appears exactly once.
  3. Check dependencies with pip install -r requirements.txt locally.
  4. Remove debugging print() calls before redeploying.

A readable console beats a long log file nobody checks.

Advertisement

Was this article helpful?

Read next