15

How to turn off / on the var/log/debug.log of Magento 2.x.x? Is there a way to set the log level?

  • Duplicate: magento.stackexchange.com/questions/95327/… – seanbreeden Nov 13 '16 at 19:55
  • Hmm, I am running this: php bin/magento config:set dev/debug/debug_logging 1 and getting this error: There are no commands defined in the "config" namespace. Did you mean one of these? app:config setup:config setup:store-config I have tried running the command with each of those instead of just config and they don't work either. Any ideas? I had this working at one time. Probably before I dumped my config. – Patrick Steil Mar 20 at 19:19
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – Jai Mar 21 at 0:32
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – Shoaib Munir Mar 21 at 3:50
28

Enabling the debug log on Magento 2.3.1

Since 2.3.1, things have changed a bit. As described in the DevDocs article here, run this command:

php bin/magento setup:config:set --enable-debug-logging=true && php bin/magento cache:flush

Enabling the debug log on Magento 2.2

In Magento 2.2, debugging can be enabled from either the GUI admin panel or from the command line.

First, check which mode your site is in by opening your Magento application directory (the one with index.php) in the shell. Then enter:

php bin/magento deploy:mode:show

If it says "production", only the command line method will work. Otherwise, the GUI method will work too.

GUI method

In the Magento admin panel, go to "Stores" -> "Configuration" -> "Advanced" -> "Developer" -> "Debug" -> "Log to File". Setting this to "Yes" will cause debug information to be logged to var/log/debug.log in your Magento application directory.

The log to File option in the control panel.

After saving the setting, you may get a prompt at the top of the page asking you to flush the cache. If this appears, flush the Magento cache with the link it gives you.

If production mode is enabled (as displayed by php bin/magento deploy:mode:show) then the GUI option will not be available. Note that this the admin panel normally hides this in production mode, so only use this if you're testing.

Command line method

First, open the Magento application directory (the one with index.php) in the shell. To enable debug logging enter:

php bin/magento config:set dev/debug/debug_logging 1 && php bin/magento cache:flush

This will cause debug information to be logged to var/log/debug.log in your Magento application directory. To disable debug logging, enter:

php bin/magento config:set dev/debug/debug_logging 0 && php bin/magento cache:flush

  • It would seem this was removed since the answer. Not applicable to 2.3.1 – Chris K Jun 19 at 18:32
  • I cannot upvote this hard enough. The old way with config:set results in "The "dev/debug/debug_logging" path does not exist" even on 2.2.8 – Fabian Schmengler Jul 25 at 10:28
3

By default, debug log is on in default or develop mode, and off in production mode.

As of Magento 2.3.1, you can no longer use the bin/magento config:set dev/debug/debug_logging 0 | 1 command to enable or disable debug logging for current mode.

Use bin/magento setup:config:set --enable-debug-logging=true or bin/magento setup:config:set --enable-debug-logging=false

0

The value you set has already been locked. To change the value, use the --lock option.

  • if you get the above message after running @Michael Casey answer, add --lock as in the following command php bin/magento config:set --lock dev/debug/debug_logging 1 && php bin/magento cache:flush – bhaskarc Dec 7 '18 at 12:33
0
bin/magento setup:config:set --enable-debug-logging=true

or

bin/magento setup:config:set --enable-debug-logging=false

Don't forget to

bin/magento cache:flush

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.