Skip to content

Enable debugger logs

Karthik Nadig edited this page Mar 26, 2020 · 5 revisions

Logging using debug configuration

You can enable debugger logs by setting "logToFile": true in the debug configuration in the launch.json for your work space. When using with ms-python.python extension the logs files will be stored in the extension root (unix/mac: ~/.vscode/extensions/ms-python.python-*, windows %USERPROFILE%\.vscode\extensions\ms-python.python-*)

{
    "name": "Python: Current File",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "console": "integratedTerminal",
    "logToFile": true
}

Logging using environment variables

Set DEBUGPY_LOG_DIR environment variable to enable debugger logs. Ensure that the path provided to DEBUGPY_LOG_DIR is a valid directory.

DEBUGPY_LOG_DIR=<path to log directory>

Logging using command line arguments

Another way to log is using CLI, see here. You can use --log-to to enable logging and provide a directory where logs should be stored.

> python3 -m debugpy --listen 5678 --wait-for-client --log-to ~/logs myscript.py
Clone this wiki locally