Magento2: It's not possible to enable "log to file" (debugging) in production mode

Created on 30 Oct 2017  路  12Comments  路  Source: magento/magento2

It's not possible to change the "dev/debug/debug_logging" sys config field while in production mode. It should definitely be set to "No" as default (like when switching from developer/default to production) but you should be allowed to change this value even while in production mode.

Preconditions

  1. Magento version 2.2 (dunno with other versions)

Steps to reproduce

  1. Switch to production mode

Expected result

  1. From the admin, go into "Stores/Configuration/Advanced/Developer/Debug/Log to file"
  2. Try to change the dropdown value, but you can't because the input is disabled

Actual result

  1. From the admin, go into "Stores/Configuration/Advanced/Developer/Debug/Log to file"
  2. You can change the dropdown value

Insights

In Magento\Deploy\etc\di.xml there is this entry:

...
<type name="Magento\Deploy\App\Mode\ConfigProvider">
    <arguments>
        <argument name="config" xsi:type="array">
            <item name="developer" xsi:type="array">
                <item name="production" xsi:type="array">
                    <item name="dev/debug/debug_logging" xsi:type="string">0</item>
                </item>
            </item>
        </argument>
    </arguments>
</type>
...

that writes this

...
'system' => array (
    'default' => array (
        'dev' => array (
            'debug' => array (
                'debug_logging' => '0',
            ),
        ),
    ),
),
...

in the env.php. The presence of this entry on the env.php disables the related input in the admin panel.

MOREOVER, if you switch from production to developer mode the entry will not be removed and so you can't change the value of the input, even if you are now in developer mode.

Fixed in 2.2.x Fixed in 2.3.x Confirmed Format is valid

Most helpful comment

Noticed strange issue here. store is in development mode despite that debug log setting showing "Not available in production mode." for developer mode it should allow write debug log. How can we solve this issue?

All 12 comments

Hmm, I thought this is intentional behavior due to debug log producing too much data on production until I saw https://github.com/magento/magento2/commit/953b4ebfce0d661bbf338cf11055399752890a9b :)

@LucaGallinari, thank you for your report. You can enable "log to file" (debugging) in production mode with SQL "INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('default', '0', 'dev/debug/debug_logging', '1');" this is not a bug.

@LucaGallinari, thank you for your report.
This seems to be correct Magento behavior. Please refer to the Community Forums or the Magento Stack Exchange site for advice or general discussion about this.
Otherwise you may submit Pull Request with the suggested changes.

I talked to PO of this feature. There was a misunderstanding in feature requirements
By default it shoud be off, but you should be able to enable debugging on production if you need it

The issue has been fixed and delivered to 2.2-develop branch. Will be available with upcoming patch release

Hi @LucaGallinari. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1351 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

  • 70dd5a3fa17e1ee1cdfaf7f0defd9276989ebbd0
  • 54bc3a1dca861e11e46e12f5a15578e0cb7ceb6d
  • 3debd3f87e27e23949b81cb2d7e881b5a269608c
  • 72c496566bf0d2ff1ced0401514faa5cbaccc0f8
  • e60ecdfeabe8b8839cf52fd5ba7fefcbb0b9bdc3
  • 8703b3da3dbe28f71c1daeaba08bbe44887f0733
  • bd88ed8cc4e1f98b791bd7ca8bed45c29b276ee1
  • 1c70b18a339fddf8a51a476a5a251aabef951350
  • 5fd7481d2cf8b298369837508a16a23ab4f49850
  • 7c615065b36cdafa95d752a891c09dd4ab1a4dfa
  • 2653b8ae55625637a6836d305451e292f881bd6a
  • 917a03f89f98454cb2ecde524dc8557d7fdcc135
  • eca73d0abd1ca6e110c364ef380adab86ab3cc1a
  • 26f3109842ce89096a49b9c122af0bae6b672ba2
  • c223484a75e38fdcece09d4586342528f06c6383
  • 3b90ad71d791ba9cf8e81cc204fd306f41473a18
  • ad317c25039de70c1a976e1139c57730899eb114
  • 53e721ccc06f1ade05132690715575bd7d47d6b7
  • 6114120c0a921b342871448dfb6c47bf34a65cdc
  • 63b483925c18304a32441f66b0db8a9c70995c73

The fix will be available with the upcoming 2.3.0 release.

Noticed strange issue here. store is in development mode despite that debug log setting showing "Not available in production mode." for developer mode it should allow write debug log. How can we solve this issue?

Same problem here...

Same problem here!

Same problem here

I had to change it in app/etc/env.php. It was set as 0. Works now.

I could add it to env.php with config:set dev/debug/debug_logging 1. Thank you :)

Was this page helpful?
0 / 5 - 0 ratings