Magento 2 Debug Mode only works in Developer Mode, so Magento 2 Application must be developer mode to enable Debug Mode.
php bin/magento deploy:mode:set developer
The following below two method , we can enable Magento 2 Debug Mode.
Method [1] – Magento 2 Admin Settings To Enable Debug Mode
Method [2] – Magento 2 CLI Command To Enable Debug Mode
Let us explain one by one
Method [1] Magento 2 Admin Settings To Enable Debug Mode
The following below admin setting required to enable Debug Mode.
Step [1] – Go To STORES > Configuration, redirects on configuration.
Step [2] – on the Configuration panel Click on Advance > Developer
Click on Right Panel tab Debug
By default all Debug mode disable
Enable Template Path Hints for Storefront:: This is used to enable Template Path Hints for Storefront by default selected No
Enable Template Path Hints for Admin:: This is used to enable Template Path Hints for Admin by default selected No
Block Class Type to Hints:: This is used to enable Block Class Type Hints for Storefront by default selected No –
Step [3] – Once click drop down menu & select Yes for all Debug mode
Enable Template Path Hints for Storefront:: — Select Yes, once select Yes, Enable Hints for Storefront with URL auto displayed & selected Yes by default
Enable Template Path Hints for Admin:: — Select Yes
Block Class Type to Hints:: — Select Yes
Step [4] – Finally Debug mode has been enabled , run CLI command flush
Step [5] – Go to storefront to view debug format
Method [2] – Magento 2 CLI Command To Enable Debug Mode
Run below CLI Command
To Enable Debug Mode
php bin/magento setup:config:set --enable-debug-logging=true
To Disable Debug Mode
php bin/magento setup:config:set --enable-debug-logging=false