PHP code example of rspeekenbrink / monolog-microsoft-teams

1. Go to this page and download the library: Download rspeekenbrink/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/ */

    

rspeekenbrink / monolog-microsoft-teams example snippets




use Monolog\Logger;
use Rspeekenbrink\MonologMicrosoftTeams\MicrosoftTeamsHandler;

// create a log channel
$log = new Logger('microsoft-teams-logger');
$log->pushHandler(new MicrosoftTeamsHandler(
    'YOUR_WEBHOOK_URL',
    'Fancy Title',
    Logger::WARNING
));

// add records to the log
$log->warning('Foo');
$log->error('Bar');



use Rspeekenbrink\MonologMicrosoftTeams\MicrosoftTeamsLogger;

// create a log channel
$log = new MicrosoftTeamsLogger(
    'YOUR_WEBHOOK_URL',
    'Fancy Title',
    Logger::WARNING
);

// add records to the log
$log->warning('Foo');
$log->error('Bar');

'teams' => [
    'driver' => 'custom',
    'via' => \Rspeekenbrink\MonologMicrosoftTeams\MicrosoftTeamsChannel::class,
    'level' => 'error',
    'url' => env('LOG_TEAMS_WEBHOOK_URL'),
    'title' => 'My Application'
],

\Log::channel('teams')->error('Oh Snap, Stuff broke again!');

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