leovince/monolog-teams

Monolog handler for sending log messages to Microsoft Teams channels via Workflows.

Maintainers

Package info

github.com/LeoVince-com/monolog-teams

pkg:composer/leovince/monolog-teams

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-05-06 06:23 UTC

This package is auto-updated.

Last update: 2026-05-06 06:39:17 UTC


README

This package provides a Monolog handler that delivers log records to a Microsoft Teams channel by calling an HTTP endpoint generated by a Teams Workflow.

Installation

You can install the package via composer:

composer require leovince/monolog-teams

Configuring Workflows on Microsoft Teams

  • In Microsoft Teams, open the Team that contains the channel intended to receive log messages.
  • Add the Workflows app to the team if it is not already installed.
  • Open the Workflows app and create a new workflow.
  • Choose the template “Send webhook alerts to a channel”.
  • When prompted, select the Team and Channel where messages should be posted.
  • The workflow will generate a unique HTTP POST URL.

Usage

use LeoVince\MonologTeams\TeamsHandler;
use Monolog\Level;
use Monolog\Logger;

// Create the logger
$log = new Logger('my_logger');
$log->pushHandler(new TeamsHandler('WEBHOOK_URL', 'APP_NAME', level: Level::Error));

// Use the logger
$log->error('Error message');

Usage with Laravel

Add to config/logging.php the following configuration under the channels key:

'teams' => [
    'driver'  => 'monolog',
    'handler' => LeoVince\MonologTeams\TeamsHandler::class,
    'level' => env('LOG_LEVEL', 'error'),
    'handler_with' => [
        'webhookUrl' => env('TEAMS_WEBHOOK_URL'),
        'name' => env('APP_NAME', 'Laravel'),
        'includeContextAndExtra' => true,
    ],
],

Add to .env the following variable:

TEAMS_WEBHOOK_URL=WEBHOOK_URL

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.