Octoxan
Octoxan

Reputation: 2299

Laravel 5.6 won't log to Slack

Currently my config/logging.php channels section contains like the following:

'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'slack'],
    ],

Then in my slack section I have set a webhook using the Incoming Webhooks section in Slack. https://slack.com/apps/A0F7XDUAZ-incoming-webhooks

Other incoming webhooks I've set for other application (not Laravel) have all worked perfectly.

When I call the following:

Log::channel('stack')->info('test'); then it successfully logs to the file, but not to Slack.

or

Log::channel('slack')->info('test'); just seemingly does nothing.

In my Slack channels as I add the configuration I can see the notification "added an integration to this channel: Laravel Log"

Not sure what else to do to even troubleshoot this or get it working?

Upvotes: 8

Views: 3348

Answers (2)

fatemeh sadeghi
fatemeh sadeghi

Reputation: 2573

if the channel level is on the debug, all kinds of log functions work. the following levels can be used for logs in order of importance

1- emergency
2-alert
3-critical
4-error
5-warning
6-notice
7-info
8-debug

and if the level you used in the channel settings should be higher than the log level. The log does not work For example, if the channel level settings are critical

Log::error($message);
Log::warning($message);
Log::notice($message);
Log::info($message);
Log::debug($message);

does not work But

Log::emergency($message);
Log::alert($message);
Log::critical($message);

they are working. So if the channel level is on the debug, all kinds of log functions work.

        'slack_channel' => [
            'driver' => 'slack',
            'url' => 'https://hooks.slack.com/services/.....',
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
//            'level' => 'critical',///<---- in critical level it`s work for Log::channel('slack_channel')->critical('message') || alert('message') || emergency('message')
            'level' => 'debug',///<---- in debug level it`s work for each type log. for example  Log::channel('slack_channel')->debug('message') || info('message') || notice('message') .... emergency('message')

        ],

Upvotes: 0

Tobias K.
Tobias K.

Reputation: 3082

Make sure info is not below the specified minimum level for messages to be escalated to Slack in config/logging.php.

Upvotes: 18

Related Questions