Download the PHP package bitbirddev/microsoft-teams-monolog-handler without Composer
On this page you can find all versions of the php package bitbirddev/microsoft-teams-monolog-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bitbirddev/microsoft-teams-monolog-handler
More information about bitbirddev/microsoft-teams-monolog-handler
Files in bitbirddev/microsoft-teams-monolog-handler
Package microsoft-teams-monolog-handler
Short Description Monolog handler sending Microsoft Teams notifications with an Incoming Webhook
License MIT
Homepage https://github.com/bitbirddev/microsoft-teams-monolog-handler
Informations about the package microsoft-teams-monolog-handler
bitbirddev Microsoft Teams Monolog Handler
A PHP package that defines custom Monolog handler to send Microsoft Teams notifications with an Incoming Webhook. The package aims to provide global messaging & log system that uses Microsoft Teams "MessageCard" notification and uses Monolog logging library.
Features
- Monolog wiring with Microsoft Teams channel
- Application error notifying
- Simple messaging
Install
Please consider running composer suggest
command to install required and missing dependencies related to framework you use (ex. Symfony):
Microsoft Teams Webhook setting
Follow these steps to set up new Webhook:
- In Microsoft Teams, choose More options (⋯) next to the channel name and then choose 'Connectors'
- Find in the list of Connectors the 'Incoming Webhook' option, and choose 'Add'
- Provide required information for the new Webhook
- Copy the Webhook url - that information will be used to configure the package with
MICROSOFT_TEAMS_WEBHOOK_URL
Symfony configuration
Place the code below in .env
file:
Register MicrosoftTeamsMonologHandler.php
as a new service with the code below:
$webhookDsn:
Microsoft Teams webhook url$level:
the minimum level for handler to be triggered and the message be logged in the channel (Monolog/Logger class: ‘error’ = 400)$title (nullable):
title of Microsoft Teams Message$subject (nullable):
subject of Microsoft Teams Message$emoji (nullable):
emoji of Microsoft Teams Message (displayed next to the message title). Value needs to reflect the pattern: ‘&#x’ $color (nullable):
hexadecimal color value for Message Card color theme$format (nullable):
every handler uses a Formatter to format the record before logging it. This attribute can be set to overwrite default log message (available options: %datetime% | %extra.token% | %channel% | %level_name% | %message%).
Modify your Monolog settings that will point from now to the new handler:
type:
handler type (in our case this references custom notifier service)id:
notifier service class \bitbirddev\MicrosoftTeamsNotifier\LogMonolog
Laravel configuration
Place the code below in .env
file:
Modify your Monolog logging settings that will point to the new handler:
Att: definition of ALL parameters is compulsory - please use NULL value for attributes you want to skip.
driver:
is a crucial part of each channel that defines how and where the log message is recorded. The ‘custom’ driver calls a specified factory to create a channel.via:
factory class which will be invoked to create the Monolog instancewebhookDsn:
Microsoft Teams webhook urllevel:
the minimum level for handler to be triggered and the message be logged in the channel (Monolog/Logger class: ‘debug’ = 100)title (nullable):
title of Microsoft Teams Messagesubject (nullable):
subject of Microsoft Teams Messageemoji (nullable):
emoji of Microsoft Teams Message (displayed next to the message title). Value needs to reflect the pattern: ‘&#x’ color (nullable):
hexadecimal color value for Message Card color themeformat (nullable):
message template - available options: %datetime% | %extra.token% | %channel% | %level_name% | %message%
Usage
Correctly configured service in Symfony/Laravel will raise Logs in Microsoft Teams automatically accordingly to level assigned to.
Symfony - manual messaging
Laravel - manual messaging
License
The code is available under the MIT license. See the LICENSE file for more info.