app-insights-php/monolog-handler
Monolog handlers for Microsoft Application Insights: send traces and dependency telemetry via AppInsightsTraceHandler and AppInsightsDependencyHandler. Supports buffering for long-running workers and enforces the 64KB telemetry size limit. Includes Laravel setup example.
StreamHandler, SyslogHandler) but adds telemetry-specific features (e.g., custom dimensions, sampling).Log facade or LogServiceProvider; requires manual handler registration.Log facade uses Monolog under the hood. Integration is feasible via:
AppServiceProvider or a dedicated logging config.Monolog configuration (e.g., config/logging.php).single, stack) may need extension to include the App Insights handler.AppInsightsHandler → Azure App Insights.AppInsightsHandler to verify log routing.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Azure SDK Dependency | High | Use PHP extension (lower latency) or HTTP fallback. Monitor SDK updates. |
| Cold Start Latency | Medium | Configure handler with retry logic for transient failures. |
| Log Volume Impact | Medium | Implement sampling in App Insights SDK or filter logs before ingestion. |
| Schema Evolution | Low | Azure App Insights handles backward-compatible schema changes. |
| Laravel Version Lock | Low | Test with Laravel 8/9/10; Monolog v2+ is stable. |
open-telemetry/php) provide a more vendor-agnostic solution?Log::error(), Log::debug() usage).AppInsightsHandler to a non-production Laravel environment.ERROR level).stack channel including AppInsightsHandler.
'channels' => [
'app_insights' => [
'driver' => 'monolog',
'handler' => AppInsightsHandler::class,
'level' => env('APP_INSIGHTS_LOG_LEVEL', 'error'),
'with' => [
'instrumentation_key' => env('APP_INSIGHTS_INSTRUMENTATION_KEY'),
],
],
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'app_insights'], // Keep local logs + App Insights
],
],
Log::error('Failed', ['user_id' => $user->id])).5xx errors).AppInsightsHandler to multiple channels)..env for APP_INSIGHTS_INSTRUMENTATION_KEY and log level.pecl install azure).composer require app-insights-php/monolog-handler.AppServiceProvider or config/logging.php.APP_INSIGHTS_LOG_LEVEL=debug (but avoid high-volume debug logs in production).app-insights-php/monolog-handler and azure/azure-sdk-for-php for breaking changes.composer.json to avoid surprises.ErrorHandler to catch handler exceptions.ERROR/WARN levels).How can I help you explore Laravel packages today?