ercorp / ms-application-insights-monolog

monolog 的 Microsoft Application Insights 集成。一个抽象处理器,将消息发送到 Microsoft Application Insights

v1.0 2018-11-12 21:56 UTC

This package is auto-updated.

Last update: 2024-09-13 12:08:00 UTC


README

Monolog 处理器连接到 Microsoft Application Insights

安装

通过 Composer:运行以下 Composer 命令

composer require ercorp/ms-application-insights-monolog

用法

提供了一个包装 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 软件包。