20

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

4
  • Duplicate: magento.stackexchange.com/questions/95327/… Commented Nov 13, 2016 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. Commented Mar 20, 2019 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
    – Jarnail S
    Commented Mar 21, 2019 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 Commented Mar 21, 2019 at 3:50

6 Answers 6

42

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

2
  • 3
    It would seem this was removed since the answer. Not applicable to 2.3.1
    – Krista K
    Commented Jun 19, 2019 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 Commented Jul 25, 2019 at 10:28
11

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

1
  • This is the right answer for Magento 2.3 and above. Thanks for your answer.
    – medina
    Commented May 8, 2020 at 10:41
2
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
2

If you run a pipe-line, or a cluster, none of the above will work, and, even worse, will bring your site down, as soon as you issue these commands. The only way to do it is to bake it into the env.php as below

'dev' =>
    array (
        'debug' =>
            array (
                'debug_logging' => 1,
            ),
        ),
1

To enable debug logging

Use the setup:config:set command to enable debug logging for the current mode.

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

Recommend to refer magento docs since things can get change with various version of products.

https://devdocs.magento.com/guides/v2.3/config-guide/cli/logging.html

0

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

1
  • 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
    Commented Dec 7, 2018 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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