How to add debugger in frappe?

I want to add debugger so how to add that please help?

1 Like

Server side you can use:

frappe.throw("What went wrong")


frappe.log_error("Write this to error log")

And client side you can use:



console.log("got it");

Thank you so much

1 Like

There’s also frappe.msgprint('debug message') for gentler debug prints on the backend.

1 Like

is it for development or preoduction??

It works for production configuration with developer_mode enabled. I didn’t test it on the pure production server yet.

1 Like

ok thanks for the reply

it works there also

1 Like

There are instructions how to setup Visual Studio Code to debug:

That way you can debug controllers and whitelisted functions. This is not an option (or only a desperate one) for your productive environment.

I also just found out how to debug code started with “bench execute …”.
This solution uses Visual Studio Code.
Your workspace must be ~/frappe-bench/apps.
Edit your launch.json and add this configuration:

`        {
        "name": "bench execute",
        "type": "python",
        "request": "launch",
        "program": "${workspaceFolder}/frappe/frappe/utils/",
        "args": [
        "python": "${workspaceFolder}/../env/bin/python",
        "cwd": "${workspaceFolder}/../sites",
        "env": {
            "DEV_SERVER": "1"


This will launch method your_method() in ~/frappe-bench/apps/yourapp/yourapp/doctype/yourdoctype/

I found this by try and error. I have no idea what "“env”: { “DEV_SERVER”: “1” } means.

1 Like