Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

longestdrive's avatar

Laravel 8: Unable to create configured logger: Slack

Hi. I'm unable to set up logging to go to a slack channel

My app has been upgraded to laravel 8 (from Laravel 5.5) and understand there were changes in logging in the config file logging.php. I've cleared the cache and config

I've copied and pasted a new config file and I believe have all the set up as documented but each time I try to log to slack I get an error.

Notifications to Slack work as expected and this is the same on my Forge and Homestead environments.

How can I log to Slack?

Here's my logging.php

<?php

use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Log Channel
    |--------------------------------------------------------------------------
    |
    | This option defines the default log channel that gets used when writing
    | messages to the logs. The name specified in this option should match
    | one of the channels defined in the "channels" configuration array.
    |
    */

    'default' => env('LOG_CHANNEL', 'stack'),

    /*
    |--------------------------------------------------------------------------
    | Log Channels
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log channels for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Drivers: "single", "daily", "slack", "syslog",
    |                    "errorlog", "monolog",
    |                    "custom", "stack"
    |
    */

    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => env('LOG_LEVEL', 'debug'),
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => storage_path('logs/laravel.log'),
            'level' => env('LOG_LEVEL', 'debug'),
            'days' => 14,
        ],

        'slack' => [
            'driver' => 'slack',
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
            'level' => env('LOG_LEVEL', 'critical'),
        ],

        'papertrail' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => SyslogUdpHandler::class,
            'handler_with' => [
                'host' => env('PAPERTRAIL_URL'),
                'port' => env('PAPERTRAIL_PORT'),
            ],
        ],

        'stderr' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => StreamHandler::class,
            'formatter' => env('LOG_STDERR_FORMATTER'),
            'with' => [
                'stream' => 'php://stderr',
            ],
        ],

        'syslog' => [
            'driver' => 'syslog',
            'level' => env('LOG_LEVEL', 'debug'),
        ],

        'errorlog' => [
            'driver' => 'errorlog',
            'level' => env('LOG_LEVEL', 'debug'),
        ],

        'null' => [
            'driver' => 'monolog',
            'handler' => NullHandler::class,
        ],

        'emergency' => [
            'path' => storage_path('logs/laravel.log'),
        ],
    ],

];

I have an environment setting for the URL: LOG_SLACK_WEBHOOK_URL="https://hooks.slack.com/services/XXXXXXXXXXXXX......"

Any advice please?

Thank you

0 likes
8 replies
longestdrive's avatar

Hi, sorry should have added that to the body of the post (added to the title) but the error is: Unable to create configured logger:

From the log I get:

Unable to create configured logger. Using emergency logger. {"exception":"[object] (TypeError(code: 0): Argument 1 passed to Monolog\Handler\SlackWebhookHandler::__construct() must be of the type string, null given, called in /home/vagrant/code/wedleague/vendor/laravel/framework/src/Illuminate/Log/LogManager.php on line 312 at /home/vagrant/code/wedleague/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php:51)
[stacktrace]
#0 /home/vagrant/code/wedleague/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(312): Monolog\Handler\SlackWebhookHandler->__construct()
#1 /home/vagrant/code/wedleague/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(202): Illuminate\Log\LogManager->createSlackDriver()
#2 /home/vagrant/code/wedleague/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(118): Illuminate\Log\LogManager->resolve()
#3 /home/vagrant/code/wedleague/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(98): Illuminate\Log\LogManager->get()
#4 /home/vagrant/code/wedleague/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(87): Illuminate\Log\LogManager->driver()
#5 /home/vagrant/code/wedleague/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(261): Illuminate\Log\LogManager->channel()
#6 /home/vagrant/code/wedleague/tests/Handlers/Events/MailerSendingEventhandlerTest.php(22): Illuminate\Support\Facades\Facade::__callStatic()
#7 /home/vagrant/code/wedleague/vendor/phpunit/phpunit/src/Framework/TestCase.php(1526): Tests\Handlers\Events\MailerSendingEventhandlerTest->testHandle()
#8 /home/vagrant/code/wedleague/vendor/phpunit/phpunit/src/Framework/TestCase.php(1132): PHPUnit\Framework\TestCase->runTest()
#9 /home/vagrant/code/wedleague/vendor/phpunit/phpunit/src/Framework/TestResult.php(722): PHPUnit\Framework\TestCase->runBare()
#10 /home/vagrant/code/wedleague/vendor/phpunit/phpunit/src/Framework/TestCase.php(884): PHPUnit\Framework\TestResult->run()
#11 /home/vagrant/code/wedleague/vendor/phpunit/phpunit/src/Framework/TestSuite.php(677): PHPUnit\Framework\TestCase->run()
#12 /home/vagrant/code/wedleague/vendor/phpunit/phpunit/src/Framework/TestSuite.php(677): PHPUnit\Framework\TestSuite->run()
#13 /home/vagrant/code/wedleague/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(667): PHPUnit\Framework\TestSuite->run()
#14 /home/vagrant/code/wedleague/vendor/phpunit/phpunit/src/TextUI/Command.php(143): PHPUnit\TextUI\TestRunner->run()
#15 /home/vagrant/code/wedleague/vendor/phpunit/phpunit/src/TextUI/Command.php(96): PHPUnit\TextUI\Command->run()
#16 /home/vagrant/code/wedleague/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#17 {main}

This is from a test I'm running simply to enter a slack log entry:

Log::channel('slack')->info("phpunit test message")

The same error occurs if I try and log in the live and local apps

Thank you

jpsmith1981's avatar

Did you ever fix this? we are getting the same error for a few months and it is driving us nutso

3 likes
mortemox's avatar

Anyone have any solutions for this? Getting the error when trying to make a debug log channel.

Yorki's avatar

This is most likely because of deprecation channel, you have two options:

First is to remove LOG_DEPRECATIONS_CHANNEL from your .env.

Second option is to add deprecations channel to your config in config/logging.php:

'channels' => [
	...
	
	'deprecations' => [
		'driver' => 'single',
		'path' => storage_path('logs/php-deprecation-warnings.log'),
	],
],
2 likes
krismanning's avatar

I'm getting the same issue after having upgraded to L9

2 likes
omoh09's avatar

I am having similar error, after an upgrade to laravel 8 using the Log facade

Please or to participate in this conversation.