soderlind / ms-application-insights-monolog
Microsoft Application Insights integration for monolog. An abstract handler that sends messages to Microsoft Application Insights
v1.0
2018-11-12 21:56 UTC
Requires
- php: ^7.1
- microsoft/application-insights: ^0.4.4
- monolog/monolog: ^1.7.0
This package is auto-updated.
Last update: 2024-12-19 23:11:26 UTC
README
Monolog Handler connection to Microsoft Application Insights
Installation
Via Composer: Run the following Composer command:
composer require soderlind/ms-application-insights-monolog
Usage
A handler is provided that wraps up a Microsoft Application Insights Telemetry client. By default the handler will grab anything at Logger::ERROR and above and send it to Microsoft Application Insights.
$logger = new Monolog\Logger("Example"); $telemetryClient = new \ApplicationInsights\Telemetry_Client(); $telemetryClient->getContext()->setInstrumentationKey('YOUR INSTRUMENTATION KEY'); $msApplicationInsightsHandler = new \ER\MSApplicationInsightsMonolog\MSApplicationInsightsHandler($telemetryClient); $logger->pushHandler($msApplicationInsightsHandler); // The following error will get sent automatically to Microsoft Application Insights $logger->addError("oh no!", array('exception' => new \Exception("ohnoception")));
Credits
This package is based on the MonoSnag package. Thanks to Steve Brazier and other contributors to that package.
The package also relies on Microsoft's ApplicationInsights-PHP package.