PHPackages                             app-insights-php/monolog-handler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. app-insights-php/monolog-handler

AbandonedArchivedLibrary[Logging &amp; Monitoring](/categories/logging)

app-insights-php/monolog-handler
================================

Microsoft App Insights monolog handler

0.3.1(3y ago)2410.1k↓48.6%7[3 issues](https://github.com/app-insights-php/monolog-handler/issues)[2 PRs](https://github.com/app-insights-php/monolog-handler/pulls)1MITPHPPHP ~8.1 || ~8.2

Since Feb 21Pushed 2y agoCompare

[ Source](https://github.com/app-insights-php/monolog-handler)[ Packagist](https://packagist.org/packages/app-insights-php/monolog-handler)[ GitHub Sponsors](https://github.com/norberttech)[ RSS](/packages/app-insights-php-monolog-handler/feed)WikiDiscussions 1.x Synced 3d ago

READMEChangelog (10)Dependencies (4)Versions (15)Used By (1)

Microsoft App Insights monolog handler
======================================

[](#microsoft-app-insights-monolog-handler)

It provides to monolog handlers for AppInsights: for tracking dependency (AppInsightsDependencyHandler) and traces (AppInsightsTraceHandler).

[![Tests](https://github.com/app-insights-php/monolog-handler/actions/workflows/tests.yml/badge.svg?branch=1.x)](https://github.com/app-insights-php/monolog-handler/actions/workflows/tests.yml)

### Long running processes

[](#long-running-processes)

It might be tricky to find a proper moment to flush everything to AppInsights for long running processes (e.g: consumers). One of the solution might be a [Buffer Handler](https://github.com/Seldaek/monolog/blob/master/src/Monolog/Handler/BufferHandler.php). You can easily wrap both handlers by Buffer Handler and set up an overflow buffer. They are designed to flush everything into AppInsight's when a buffer overflows.

### Limitations

[](#limitations)

Size of the telemetry is limited to [64 kilobytes](https://docs.microsoft.com/en-us/azure/azure-monitor/service-limits#application-insights). Handlers checks the length of the telemetry before adding it to the AppInsights Client's queue. If it exceeds the limit **it won't be added!** It means that AppInsights should not be the only source for your data. You should always have a copy somewhere else where you don't have such limitations.

### Usage example in Laravel:

[](#usage-example-in-laravel)

1. Update config/logging.php with a new entry:

```
'appinsights' => [
            'driver' => 'monolog',
            'level' => 'debug',
            'handler' => \AppInsightsPHP\Monolog\Handler\AppInsightsTraceHandler::class,
            'formatter' => \AppInsightsPHP\Monolog\Formatter\ContextFlatterFormatter::class
        ],

```

2. Register a new service provider

```
php artisan make:provider AppInsightsLogProvider

```

2.1 Register servicer provider dependencies for the log handler in the `boot()` method.

```
/**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        $this->app->bind(
            AppInsightsTraceHandler::class,
            function ($app) {
                $telemetryClient = new \ApplicationInsights\Telemetry_Client();
                $context = $telemetryClient->getContext();
                $context->setInstrumentationKey(env('APPINSIGHTS_INSTRUMENTATIONKEY'));

                /** @var CacheManager $cacheManager */
                $failureCache = new FailureCache(Cache::repository(new NullStore()));

                /** @var Logger $defaultLogger */
                $defaultLogger = Log::getFacadeRoot();

                $client = new Client($telemetryClient, Configuration::createDefault(), $failureCache, $defaultLogger);

                $handler = new AppInsightsTraceHandler($client);

                return $handler;
            }
        );

```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~179 days

Recently: every ~268 days

Total

11

Last Release

893d ago

Major Versions

0.3.1 → 1.x-dev2024-01-23

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/52325810?v=4)[norbert-tech](/maintainers/norbert-tech)[@norbert-tech](https://github.com/norbert-tech)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (64 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (22 commits)")[![norberttech](https://avatars.githubusercontent.com/u/1921950?v=4)](https://github.com/norberttech "norberttech (19 commits)")[![aeon-automation](https://avatars.githubusercontent.com/u/77585774?v=4)](https://github.com/aeon-automation "aeon-automation (15 commits)")[![tomaszhanc](https://avatars.githubusercontent.com/u/7013293?v=4)](https://github.com/tomaszhanc "tomaszhanc (7 commits)")[![drmmr763](https://avatars.githubusercontent.com/u/643104?v=4)](https://github.com/drmmr763 "drmmr763 (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/app-insights-php-monolog-handler/health.svg)

```
[![Health](https://phpackages.com/badges/app-insights-php-monolog-handler/health.svg)](https://phpackages.com/packages/app-insights-php-monolog-handler)
```

###  Alternatives

[symfony/monolog-bridge

Provides integration for Monolog with various Symfony components

2.6k203.8M358](/packages/symfony-monolog-bridge)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[illuminate/log

The Illuminate Log package.

6225.3M623](/packages/illuminate-log)[spatie/flare-client-php

Send PHP errors to Flare

177161.5M23](/packages/spatie-flare-client-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[graycore/magento2-stdlogging

A Magento 2 module that changes all logging handlers to stdout

2587.9k](/packages/graycore-magento2-stdlogging)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
