marchie / ms-application-insights-monolog
monolog 的 Microsoft Application Insights 集成。一个抽象处理程序,将消息发送到 Microsoft Application Insights
dev-master
2015-08-05 14:44 UTC
Requires
- microsoft/application-insights: ^0.3.0
- monolog/monolog: ^1.7.0
This package is not auto-updated.
Last update: 2024-09-14 17:58:53 UTC
README
Monolog 处理程序连接到 Microsoft Application Insights
安装
通过 Composer: 在你的 composer.json 中添加以下内容
"require": { "marchie/ms-application-insights-monolog": "dev-master" }
用法
提供了一个处理程序,它包装了一个 Microsoft Application Insights 遥测客户端。默认情况下,处理程序将捕获 Logger::ERROR 及以上的所有内容并发送到 Microsoft Application Insights。
$logger = new Monolog\Logger("Example"); $telemetryClient = new \ApplicationInsights\Telemetry_Client(); $telemetryClient->getContext()->setInstrumentationKey('YOUR INSTRUMENTATION KEY'); $msApplicationInsightsHandler = new \Marchie\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")));
致谢
此包基于 MonoSnag 包。感谢 Steve Brazier 及其他对该包的贡献者。
该包还依赖于 Microsoft 的 ApplicationInsights-PHP 包。