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)2401.0k—7.9%7[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 1mo 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

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity70

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

847d 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.6k189.7M258](/packages/symfony-monolog-bridge)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[illuminate/log

The Illuminate Log package.

6224.3M518](/packages/illuminate-log)[honeybadger-io/honeybadger-php

Honeybadger PHP library

381.5M4](/packages/honeybadger-io-honeybadger-php)[graycore/magento2-stdlogging

A Magento 2 module that changes all logging handlers to stdout

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

PHPackages © 2026

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