-
Notifications
You must be signed in to change notification settings - Fork 137
Enable debugger logs
In a "launch" configuration only, you can enable debugger logs by setting "logToFile": true
in the debug configuration in the launch.json
for your work space.
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"logToFile": true,
}
When debugpy is used with Python Debugger extension for VSCode (ms-python.debugpy
), the logs files will be stored in the folder into which the extension is installed:
-
Windows:
%USERPROFILE%\.vscode\extensions\ms-python.debugpy-*
-
Unix/Mac:
~/.vscode/extensions/ms-python.debugpy-*
-- Note: to open the extensions folder from VSCode it's possible to use the command: Extensions: Open Extensions Folder
.
Set the 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=~/logs
For "launch" configurations, the variable needs to be set in the environment used by the debugger client. For example, for VSCode SSH remoting, it needs to be set on the remote machine.
For "attach" configurations, the variable needs to be set in the environment in which the debugged application is running.
For "attach" scenarios, another way to log is using the CLI. 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