randomcast's avatar

Unable to disable deprecations logging

I cannot seem to disable deprecations loggings/attempts of loggings, running Laravel 9.11.

My logging.php config file is not altered, containing:

    'deprecations' => [
        'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
        'trace' => false,
    ],

and my env file has

LOG_DEPRECATIONS_CHANNEL=null

However, i still keep getting deprecations logging attempts, where the logger logs deprecations in regular app log because it can't seem to find deprecations logging config {"exception":"[object] (InvalidArgumentException(code: 0): Log [deprecations] is not defined..

I can create a deprecations logging channel like this in logging.php

        ...
        'deprecations' => [
		    'driver' => 'single',
		    'path' => storage_path('logs/php-deprecation-warnings.log'),
	    ],

but i want to disable them completely.

Why is Laravel ignoring LOG_DEPRECATIONS_CHANNEL=null?

1 like
1 reply
MortenS's avatar

I was also stumped by this, but it's actually explained in the docs:

Or, you may define a log channel named deprecations. If a log channel with this name exists, it will always be used to log deprecations

So if you want to be able to toggle deprecation logging on/off via .env, you have to rename the deprecations channel to something else.

Please or to participate in this conversation.