PHPackages                             jmluang/logtailer-client-sdk - 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. jmluang/logtailer-client-sdk

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

jmluang/logtailer-client-sdk
============================

Logtailer Client SDK for PHP - Log aggregation service client

v1.0(9mo ago)041MITPHPPHP &gt;=8.1

Since Sep 21Pushed 9mo agoCompare

[ Source](https://github.com/jmluang/logtailer-client-sdk)[ Packagist](https://packagist.org/packages/jmluang/logtailer-client-sdk)[ RSS](/packages/jmluang-logtailer-client-sdk/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Jmluang Logtailer Client SDK
============================

[](#jmluang-logtailer-client-sdk)

A PHP SDK for integrating with Logtailer log aggregation service, with full Monolog 3.x support.

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

[](#installation)

```
composer require jmluang/logtailer-client-sdk
```

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- ext-curl
- ext-json
- monolog/monolog ^3.0

Laravel Integration
-------------------

[](#laravel-integration)

### Step 1: Install the package

[](#step-1-install-the-package)

```
composer require jmluang/logtailer-client-sdk
```

### Step 2: Add configuration to .env

[](#step-2-add-configuration-to-env)

```
LOGTAILER_TOKEN=your-source-token-here
LOGTAILER_ENDPOINT=http://localhost:8080/logs
LOGTAILER_ENABLED=true
```

### Step 3: Configure Laravel Logging

[](#step-3-configure-laravel-logging)

Add this channel to your `config/logging.php`:

```
'channels' => [
    'logtailer' => [
        'driver' => 'custom',
        'via' => function () {
            $handler = new \Jmluang\Logtailer\Monolog\LogtailHandler(
                env('LOGTAILER_TOKEN'),
                \Monolog\Level::Debug,
                true,
                env('LOGTAILER_ENDPOINT', 'http://localhost:8080/logs')
            );
            return new \Monolog\Logger('logtailer', [$handler]);
        },
    ],

    'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'logtailer'],
    ],
],
```

### Step 4: Use in your application

[](#step-4-use-in-your-application)

```
Log::info('User logged in', ['user_id' => $user->id]);
Log::error('Payment failed', ['order_id' => $orderId]);
```

Standard PHP Usage
------------------

[](#standard-php-usage)

### Basic Usage with LogtailHandler

[](#basic-usage-with-logtailhandler)

```
use Monolog\Logger;
use Monolog\Level;
use Jmluang\Logtailer\Monolog\LogtailHandler;

$logger = new Logger('my-app');

$handler = new LogtailHandler(
    'your-source-token',
    Level::Debug,
    true,
    'http://localhost:8080/logs'
);

$logger->pushHandler($handler);

// Use logger as normal
$logger->info('Application started');
$logger->error('An error occurred', ['error_code' => 500]);
```

### Using the Builder Pattern

[](#using-the-builder-pattern)

```
use Jmluang\Logtailer\Monolog\LogtailHandlerBuilder;

$handler = LogtailHandlerBuilder::withSourceToken('your-token')
    ->withEndpoint('http://localhost:8080/logs')
    ->withLevel(Level::Info)
    ->withBufferLimit(500)
    ->withFlushIntervalMilliseconds(3000)
    ->build();

$logger->pushHandler($handler);
```

Testing
-------

[](#testing)

### Install Dependencies

[](#install-dependencies)

```
composer install
```

### Run Tests

[](#run-tests)

```
# Run all tests with documentation
./vendor/bin/phpunit --testdox

# Run tests with coverage report
./vendor/bin/phpunit --coverage-text

# Run specific test file
./vendor/bin/phpunit tests/Monolog/LogtailHandlerTest.php

# Run integration tests (requires running Logtailer service)
LOGTAILER_INTEGRATION_TEST=1 ./vendor/bin/phpunit --group integration
```

### Test Structure

[](#test-structure)

```
tests/
├── Monolog/
│   ├── LogtailClientTest.php       # HTTP client tests
│   ├── LogtailFormatterTest.php    # JSON formatter tests
│   ├── LogtailHandlerTest.php      # Buffer handler tests
│   ├── LogtailHandlerBuilderTest.php # Builder pattern tests
│   └── SynchronousLogtailHandlerTest.php # Sync handler tests

```

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

[](#configuration-options)

### LogtailHandler

[](#logtailhandler)

- `sourceToken` (string): Authentication token for Logtailer
- `level` (Level): Minimum log level (default: Debug)
- `bubble` (bool): Whether to bubble messages (default: true)
- `endpoint` (string): Logtailer endpoint URL
- `bufferLimit` (int): Max buffered entries (default: 1000)
- `flushOnOverflow` (bool): Flush when buffer is full (default: true)
- `connectionTimeoutMs` (int): Connection timeout in ms (default: 5000)
- `timeoutMs` (int): Request timeout in ms (default: 5000)
- `flushIntervalMs` (int|null): Auto-flush interval in ms (default: 5000)

Examples
--------

[](#examples)

### Logging with Context

[](#logging-with-context)

```
$logger->info('User action', [
    'user_id' => 123,
    'action' => 'login',
    'ip' => '192.168.1.1',
    'metadata' => [
        'browser' => 'Chrome',
        'os' => 'macOS'
    ]
]);
```

### Exception Logging

[](#exception-logging)

```
try {
    // Some operation
} catch (\Exception $e) {
    $logger->error('Operation failed', [
        'exception' => $e
    ]);
}
```

### Multiple Channels

[](#multiple-channels)

```
$apiLogger = new Logger('api');
$apiLogger->pushHandler($handler);

$dbLogger = new Logger('database');
$dbLogger->pushHandler($handler);

$apiLogger->info('API request received');
$dbLogger->info('Database query executed');
```

License
-------

[](#license)

MIT

Support
-------

[](#support)

For issues and feature requests, please open an issue on GitHub.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance57

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

286d ago

### Community

Maintainers

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

---

Top Contributors

[![jmluang](https://avatars.githubusercontent.com/u/11557732?v=4)](https://github.com/jmluang "jmluang (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jmluang-logtailer-client-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/jmluang-logtailer-client-sdk/health.svg)](https://phpackages.com/packages/jmluang-logtailer-client-sdk)
```

###  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)
