PHPackages                             maidomax/laravel-datadog-logger - 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. maidomax/laravel-datadog-logger

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

maidomax/laravel-datadog-logger
===============================

A Laravel package for logging to Datadog via HTTP API

v1.0.1(7mo ago)0193MITPHPPHP ^8.0CI passing

Since Sep 24Pushed 7mo agoCompare

[ Source](https://github.com/Maidomax/laravel-datadog-logger)[ Packagist](https://packagist.org/packages/maidomax/laravel-datadog-logger)[ Docs](https://github.com/Maidomax/laravel-datadog-logger)[ RSS](/packages/maidomax-laravel-datadog-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

Laravel Datadog Logger
======================

[](#laravel-datadog-logger)

A Laravel package that provides seamless integration with Datadog's HTTP log intake API, allowing you to send your Laravel application logs directly to Datadog for centralized logging and monitoring.

Features
--------

[](#features)

- 🚀 Easy integration with Laravel's logging system
- 🌍 Support for all Datadog regions (US, EU, US3, US5)
- 🏷️ Automatic tagging with service name and environment
- ⚡ HTTP-based log transmission to Datadog
- 🔧 Configurable via environment variables or config file
- 📦 Auto-discovery support for Laravel 5.5+

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

[](#installation)

You can install the package via Composer:

```
composer require maidomax/laravel-datadog-logger
```

### Laravel Auto-Discovery

[](#laravel-auto-discovery)

For Laravel 5.5+ with package auto-discovery enabled, the service provider will be automatically registered. For older versions, add the service provider to your `config/app.php`:

```
'providers' => [
    // ...
    Maidomax\DatadogLogger\DatadogLoggerServiceProvider::class,
],
```

### Publish Configuration (Optional)

[](#publish-configuration-optional)

You can publish the configuration file to customize the package settings:

```
php artisan vendor:publish --tag=datadog-logger-config
```

This will create a `config/datadog-logger.php` file where you can customize the package settings.

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

[](#configuration)

### Environment Variables

[](#environment-variables)

Add the following environment variables to your `.env` file:

```
# Required: Your Datadog API Key
DATADOG_API_KEY=your_datadog_api_key_here

# Required: Datadog Log Intake URL for your region
# US: https://http-intake.logs.datadoghq.com/api/v2/logs
# EU: https://http-intake.logs.datadoghq.eu/api/v2/logs
# US3: https://http-intake.logs.us3.datadoghq.com/api/v2/logs
# US5: https://http-intake.logs.us5.datadoghq.com/api/v2/logs
DATADOG_LOG_INTAKE_URL=https://http-intake.logs.datadoghq.com/api/v2/logs

# Optional: Service name (defaults to 'laravel')
DATADOG_SERVICE=my-laravel-app

# Optional: Environment (defaults to APP_ENV, then 'local')
DATADOG_ENVIRONMENT=production

# Optional: Data source identifier (defaults to 'laravel')
DATADOG_SOURCE=my-custom-source

# Optional: HTTP timeout in seconds (defaults to 5)
DATADOG_TIMEOUT=10

# Optional: Connection timeout in seconds (defaults to 3)
DATADOG_CONNECTION_TIMEOUT=5
```

### Laravel Logging Configuration

[](#laravel-logging-configuration)

Add the Datadog logging channel to your `config/logging.php`:

```
'channels' => [
    // ... other channels

    'datadog' => [
        'driver' => 'datadog',
        'api_key' => env('DATADOG_API_KEY'),
        'intake_url' => env('DATADOG_LOG_INTAKE_URL'),
        'service' => env('DATADOG_SERVICE'),
        'environment' => env('DATADOG_ENVIRONMENT'),
        'source' => env('DATADOG_SOURCE'),
        'timeout' => env('DATADOG_TIMEOUT', 5),
        'connection_timeout' => env('DATADOG_CONNECTION_TIMEOUT', 3),
    ],

    // Example: Use Datadog alongside other logging channels
    'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'datadog'],
        'ignore_exceptions' => false,
    ],
],
```

### Set Default Log Channel

[](#set-default-log-channel)

Update your `.env` file to use the stack channel (or directly use datadog):

```
LOG_CHANNEL=stack
```

Usage
-----

[](#usage)

Once configured, you can use Laravel's standard logging methods and they will be sent to Datadog:

```
use Illuminate\Support\Facades\Log;

// These will be sent to Datadog (and other configured channels)
Log::emergency('System is down!');
Log::alert('High CPU usage detected');
Log::critical('Database connection failed');
Log::error('User authentication failed', ['user_id' => 123]);
Log::warning('Deprecated API endpoint used');
Log::notice('User logged in', ['user_id' => 456]);
Log::info('Order processed successfully', ['order_id' => 789]);
Log::debug('Debug information', ['data' => $someData]);

// Using specific channel
Log::channel('datadog')->info('This goes directly to Datadog');

// With context
Log::info('User action performed', [
    'user_id' => 123,
    'action' => 'purchase',
    'amount' => 99.99,
    'ip_address' => request()->ip(),
]);
```

Log Structure
-------------

[](#log-structure)

Logs sent to Datadog will include the following fields:

- `ddsource`: Data source identifier (configurable via `DATADOG_SOURCE`, defaults to "laravel")
- `ddtags`: Environment and service tags (e.g., "env:production,service:my-app")
- `hostname`: Server hostname
- `message`: The log message
- `level`: Log level (emergency, alert, critical, error, warning, notice, info, debug)
- `timestamp`: Unix timestamp in milliseconds
- `context`: Additional context data passed to the log
- `extra`: Extra data from Monolog processors

Datadog Regions
---------------

[](#datadog-regions)

This package supports all Datadog regions. Make sure to use the correct intake URL for your region:

RegionIntake URLUS`https://http-intake.logs.datadoghq.com/api/v2/logs`EU`https://http-intake.logs.datadoghq.eu/api/v2/logs`US3`https://http-intake.logs.us3.datadoghq.com/api/v2/logs`US5`https://http-intake.logs.us5.datadoghq.com/api/v2/logs`Error Handling
--------------

[](#error-handling)

If the package fails to send logs to Datadog (e.g., network issues, invalid API key), it will:

1. Not throw exceptions to avoid breaking your application
2. Log the error to PHP's error log for debugging
3. Continue processing other log channels in your stack

Performance Considerations
--------------------------

[](#performance-considerations)

- Log transmission to Datadog is performed synchronously via HTTP requests
- Failed requests have a configurable timeout (default 5 seconds) to prevent hanging
- For high-volume applications or to avoid blocking, consider using a queue-based logging solution

Testing
-------

[](#testing)

```
composer test
```

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

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Maidomax](https://github.com/Maidomax)

License
-------

[](#license)

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

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for more information on what has changed recently.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance64

Regular maintenance activity

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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

Total

2

Last Release

216d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/121efe9e2b4f4ce3e5f85166a3ae22a282b0c63b877a74092a4ef75404785987?d=identicon)[Maidomax](/maintainers/Maidomax)

---

Top Contributors

[![Maidomax](https://avatars.githubusercontent.com/u/1213091?v=4)](https://github.com/Maidomax "Maidomax (8 commits)")

---

Tags

laravelloggingDataDogmonologobservability

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/maidomax-laravel-datadog-logger/health.svg)

```
[![Health](https://phpackages.com/badges/maidomax-laravel-datadog-logger/health.svg)](https://phpackages.com/packages/maidomax-laravel-datadog-logger)
```

###  Alternatives

[naoray/laravel-github-monolog

Log driver to store logs as github issues

10619.4k](/packages/naoray-laravel-github-monolog)[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)
