Skip to content

ssswang/monolog-microsoft-teams

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

monolog-microsoft-teams

Monolog Handler for sending messages to Microsoft Teams channels using the Incoming WebHook connector.

Install

$ composer require ssswang/monolog-microsoft-teams

Usage

You need webhook_url from Teams and also set mininum level of log message to be sent

$logger = new \Monolog\Logger('app');
$logger->pushHandler(new \MonologMicrosoftTeams\TeamsLogHandler(env('TEAMS_WEBHOOK_URL'), \Monolog\Logger::ERROR));

Usage with Laravel 5.4~5.5

$monolog = \Log::getMonolog();
$teamsHandler = new \MonologMicrosoftTeams\TeamsLogHandler(env('TEAMS_WEBHOOK_URL'), \Monolog\Logger::NOTICE);
$monolog->pushHandler($teamsHandler);

Usage with Laravel/Lumen framework (5.6+)

Create a custom channel

config/logging.php

'teams' => [
    'driver' => 'custom',
    'via' => \MonologMicrosoftTeams\TeamsLogChannel::class,
    'level' => 'error',
    'url' => 'INCOMING_WEBHOOK_URL',
],

Send an error message to the teams channel:

Log::channel('teams')->error('Error message\n\nDouble slash n To start new line.');

You can also add teams to the default stack channel so all errors are automatically send to the teams channel.

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

License

monolog-microsoft-teams is available under the MIT license. See the LICENSE file for more info.

About

Monolog Handler for sending messages to Microsoft Teams channels

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%