PHPackages                             changole/otel-logging - 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. changole/otel-logging

ActiveLibrary

changole/otel-logging
=====================

OpenTelemetry log handler for Laravel applications that sends logs to OTLP-compatible collectors

v1.1.2(2mo ago)55.4k↓33.3%MITPHPPHP ^8.0CI passing

Since Mar 1Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/EmmanuelChangole/otel-logging)[ Packagist](https://packagist.org/packages/changole/otel-logging)[ RSS](/packages/changole-otel-logging/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (16)Versions (15)Used By (0)

Laravel OpenTelemetry Logging
=============================

[](#laravel-opentelemetry-logging)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0e44ca3dc3c497878ee3caa392c363a812a6ac8ce13a58abc0087207a162e7bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368616e676f6c652f6f74656c2d6c6f6767696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/changole/otel-logging)[![Total Downloads](https://camo.githubusercontent.com/bf03e7bc8c925bf7007cd01dc9fb569e8354ea3deb2a7b5a8ba488bfb204cb87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368616e676f6c652f6f74656c2d6c6f6767696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/changole/otel-logging)[![License](https://camo.githubusercontent.com/8958ce728cdb39bea65d599264c17b3fe94f0f2cf3247c239436c6f35206a4de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6368616e676f6c652f6f74656c2d6c6f6767696e673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/changole/otel-logging)[![Tests](https://github.com/EmmanuelChangole/otel-logging/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/EmmanuelChangole/otel-logging/actions/workflows/tests.yml)

A Laravel package that seamlessly integrates with OpenTelemetry by sending your application logs to OpenTelemetry collectors using the OTLP protocol.

Features
--------

[](#features)

- 🔄 Sends Laravel logs to an OpenTelemetry collector
- 🧩 Properly formats log attributes according to OTLP specification
- 🛡️ Handles exceptions gracefully with comprehensive error reporting
- ⚙️ Configurable via environment variables or config file
- 🔍 Supports distributed tracing context (trace and span IDs)
- 🔌 Compatible with Laravel 8, 9, 10, 11 and 12

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require changole/otel-logging
```

Configuration
-------------

[](#configuration)

### Publishing the Configuration

[](#publishing-the-configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=otel-logging-config
```

This will create a `config/otel-logging.php` file where you can configure the package.

### Environment Variables

[](#environment-variables)

Configure the package using environment variables in your `.env` file:

```
OTEL_ENABLED=true
OTEL_EXPORTER_ENDPOINT=https://collector.example.com/v1/logs
OTEL_SERVICE_NAME=my-laravel-app
OTEL_HTTP_TIMEOUT=5
```

Usage
-----

[](#usage)

### Configure the Logging Channel

[](#configure-the-logging-channel)

Add the OpenTelemetry channel to your logging configuration in `config/logging.php`:

```
'channels' => [
    // ...
    'otel' => [
        'driver' => 'monolog',
        'handler' => Changole\OtelLogging\Otel\OtelLogHandler::class,
    ],

    // Or use it in a stack
    'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'otel'],
        'ignore_exceptions' => false,
    ],
],
```

### Basic Usage

[](#basic-usage)

Once configured, the handler will automatically send logs to your OpenTelemetry collector:

```
// Using the dedicated channel
Log::channel('otel')->info('This is a test message', ['user_id' => 123]);

// Or when using the stack (if you added 'otel' to your stack channels)
Log::info('This message will go to both file and OpenTelemetry', [
    'user_id' => 123,
]);
```

### Logging Exceptions

[](#logging-exceptions)

Exception details are automatically formatted according to OpenTelemetry conventions:

```
try {
    // Your code
} catch (\Exception $e) {
    Log::error('Error processing payment', [
        'exception' => $e,
        'payment_id' => $paymentId,
    ]);
}
```

### Distributed Tracing

[](#distributed-tracing)

Add trace and span IDs to correlate logs with traces:

```
Log::info('Processing order', [
    'order_id' => $order->id,
    'trace_id' => $traceId,
    'span_id' => $spanId,
]);
```

Configuration Options
---------------------

[](#configuration-options)

Environment VariableDescriptionDefault`OTEL_ENABLED`Enable or disable OpenTelemetry logging`false``OTEL_EXPORTER_ENDPOINT`The URL of the OpenTelemetry collector`https://collector.example.com/v1/logs``OTEL_SERVICE_NAME`The name of your service`laravel-app``OTEL_HTTP_TIMEOUT`Timeout for HTTP requests in seconds`5`Troubleshooting
---------------

[](#troubleshooting)

### Logs aren't being sent to the collector

[](#logs-arent-being-sent-to-the-collector)

1. Check that `OTEL_ENABLED` is set to `true` in your `.env` file
2. Verify your collector endpoint is correct and accessible
3. Check your Laravel logs for any error messages related to sending logs

### Performance considerations

[](#performance-considerations)

The package is designed to have minimal impact on performance, but if you're concerned about performance in high-volume environments:

1. Consider using a batched collector endpoint
2. Set an appropriate log level to reduce the volume of logs

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Credits
-------

[](#credits)

- [Emmanuel Changole](https://github.com/EmmanuelChangole)
- [All Contributors](../../contributors)

About OpenTelemetry
-------------------

[](#about-opentelemetry)

[OpenTelemetry](https://opentelemetry.io/) is a collection of tools, APIs, and SDKs used to instrument, generate, collect, and export telemetry data (logs) for analysis in order to understand what is happening on your software's.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance84

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~28 days

Recently: every ~77 days

Total

14

Last Release

80d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2bcc36b6d5d040ac2ae7aab3ce3ec57cc789d9cf5dce16c62e6b8f1670749b3?d=identicon)[changole](/maintainers/changole)

---

Top Contributors

[![EmmanuelChangole](https://avatars.githubusercontent.com/u/33663667?v=4)](https://github.com/EmmanuelChangole "EmmanuelChangole (1 commits)")

---

Tags

laravel-logging-observability

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/changole-otel-logging/health.svg)

```
[![Health](https://phpackages.com/badges/changole-otel-logging/health.svg)](https://phpackages.com/packages/changole-otel-logging)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)

PHPackages © 2026

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