PHP code example of ssswang / monolog-microsoft-teams

1. Go to this page and download the library: Download ssswang/monolog-microsoft-teams library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ssswang / monolog-microsoft-teams example snippets


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

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

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

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

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