Monolog Handler for sending messages to Microsoft Teams using the Incoming Webhook connector

1.2.0 2021-01-26 12:33 UTC

This package is auto-updated.

Last update: 2024-05-26 20:04:28 UTC


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


$ composer require culy/monolog-microsoft-teams


$logger = new \Culy\Microsoft\Teams\TeamsLogger('INCOMING_WEBHOOK_URL', \Monolog\Logger::ERROR);
$logger->error('Error message');


$logger = new \Monolog\Logger('app');
$logger->pushHandler(new \Culy\Microsoft\Teams\TeamsLogHandler('INCOMING_WEBHOOK_URL', \Monolog\Logger::ERROR));

Usage with Laravel/Lumen framework (5.6+)

Create a custom channel


'teams' => [
    'driver' => 'custom',
    'via' => \Culy\Microsoft\Teams\TeamsLogChannel::class,
    'level' => 'error',
    'url' => 'INCOMING_WEBHOOK_URL',

Send an error message to the teams channel:

Log::channel('teams')->error('Error message');

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'],

Unit testing · PhpUnit

The tests require a valid Teams Incoming Webhook URL. To provide this URL to PhpUnit, copy phpunit.xml.dist to phpunit.xmland set the URL in the <php> section. Make sure to not commit your local phpunit.xml into the repo!

    <env name="TEAMS_INCOMING_WEBHOOK_URL" value="" />

Run the tests on the command line:

$ composer test


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