Skip to content

Instantly share code, notes, and snippets.

@owenconti
Last active August 3, 2021 16:47
Show Gist options
  • Save owenconti/e77b882becaf759933231009afcf807b to your computer and use it in GitHub Desktop.
Save owenconti/e77b882becaf759933231009afcf807b to your computer and use it in GitHub Desktop.
Logging messages to Slack channels with Laravel
<?php
return [
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Oh See Snaps',
'emoji' => ':boom:',
'level' => 'error'
],
'slackNotification' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Oh See Snaps',
'emoji' => ':wave:',
'level' => 'info'
]
];
// .env
LOG_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXXXXX
<?php
Log::channel('slackNotification')->info('New user created', [
'name' => $user->name,
'email' => $user->email
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment