PHPackages                             pgtruesdell/laravel-logsnag - 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. pgtruesdell/laravel-logsnag

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

pgtruesdell/laravel-logsnag
===========================

Logsnag's realtime monitoring + your Laravel project = 😎

2.0(3mo ago)3129[4 PRs](https://github.com/pgtruesdell/laravel-logsnag/pulls)MITPHPPHP ^8.2CI passing

Since Aug 6Pushed 1mo ago1 watchersCompare

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

READMEChangelog (6)Dependencies (13)Versions (15)Used By (0)

Laravel LogSnag
===============

[](#laravel-logsnag)

[![Latest Version on Packagist](https://camo.githubusercontent.com/75236dfbe8fe77894d1d4dbed90487f7d3e06f344e529e7001a1afe28e1f0052/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7067747275657364656c6c2f6c61726176656c2d6c6f67736e61672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pgtruesdell/laravel-logsnag)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8a3b722bd2abd8b5b68290e5a3a30eec1c24c2833dce117313555c6a587f59cd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7067747275657364656c6c2f6c61726176656c2d6c6f67736e61672f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/pgtruesdell/laravel-logsnag/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/eb4702f8992056bcc48271d5d85c9946b1dcf1d81fb4e9d02be7ca872ca2e602/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7067747275657364656c6c2f6c61726176656c2d6c6f67736e61672f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/pgtruesdell/laravel-logsnag/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/66204ad6045631003d9f24e9e1756f0d49cb1e71836982c83b6e32f692c22d7a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7067747275657364656c6c2f6c61726176656c2d6c6f67736e61672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pgtruesdell/laravel-logsnag)

A full-featured Laravel integration for [LogSnag](https://logsnag.com)'s real-time event tracking API. Track events, monitor metrics, identify users, and pipe your Laravel logs straight to LogSnag.

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

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12

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

[](#installation)

```
composer require pgtruesdell/laravel-logsnag
```

Publish the config file:

```
php artisan vendor:publish --tag="laravel-logsnag-config"
```

Add your LogSnag credentials to `.env`:

```
LOGSNAG_TOKEN=your-api-token
LOGSNAG_PROJECT=your-project-slug
```

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

[](#configuration)

The published config file (`config/logsnag.php`) contains:

```
return [
    // Your LogSnag project slug
    'project' => env('LOGSNAG_PROJECT', 'my-laravel-app'),

    // Default channel for the Monolog driver
    'channel' => env('LOGSNAG_CHANNEL', 'app-events'),

    // Your LogSnag API token
    'token' => env('LOGSNAG_TOKEN', ''),

    // Icon mapping for the Monolog driver (keyed by Monolog level name)
    'icons' => [
        'Debug'     => 'ℹ️',
        'Info'      => 'ℹ️',
        'Notice'    => '📌',
        'Warning'   => '⚠️',
        'Error'     => '⚠️',
        'Critical'  => '🔥',
        'Alert'     => '🔔️',
        'Emergency' => '💀',
    ],
];
```

Usage
-----

[](#usage)

The package provides three ways to interact with LogSnag: **helper functions**, the **Facade**, or by resolving the **`Logsnag` class** from the container. All three offer the same API.

### Log Events

[](#log-events)

Track events happening in your application.

```
use PGT\Logsnag\Facades\Logsnag;

// Minimal
Logsnag::log(channel: 'waitlist', event: 'User Signed Up');

// With all options
Logsnag::log(
    channel: 'billing',
    event: 'Subscription Renewed',
    description: 'Pro plan renewed for another year.',
    icon: '💳',
    notify: true,
    tags: ['plan' => 'pro', 'cycle' => 'yearly'],
    parser: \PGT\Logsnag\Enums\Parser::Markdown,
    userId: 'user-123',
    timestamp: now()->subMinutes(5)->timestamp,
);
```

Or with the helper function:

```
logsnag(
    channel: 'waitlist',
    event: 'User Signed Up',
    description: 'A new user joined the waitlist.',
    icon: '🎉',
);
```

**Parameters:**

ParameterTypeDefaultDescription`channel``string`*required*Event channel/category`event``string`*required*Event name`description``?string``null`Event description (supports Markdown when parser is set)`icon``?string``null`Emoji icon`notify``bool``false`Send push notification`tags``?array``null`Key-value tags for filtering`parser``?Parser``null``Parser::Markdown` or `Parser::Text``userId``?string``null`Associate event with a user`timestamp``?int``null`Unix timestamp (backdate events)### Insights

[](#insights)

Create or set a metric value.

```
use PGT\Logsnag\Facades\Logsnag;

Logsnag::insight(title: 'Total Users', value: 1250, icon: '👥');
Logsnag::insight(title: 'MRR', value: 14999.99, icon: '💰');
Logsnag::insight(title: 'Status', value: 'Operational');
```

Or with the helper:

```
insight(title: 'Total Users', value: 1250, icon: '👥');
```

**Parameters:**

ParameterTypeDefaultDescription`title``string`*required*Metric name`value``string|int|float`*required*Metric value`icon``?string``null`Emoji icon### Mutate Insights

[](#mutate-insights)

Increment or decrement an existing metric without knowing its current value.

```
use PGT\Logsnag\Facades\Logsnag;

// Increment
Logsnag::mutateInsight(title: 'API Calls', incrementBy: 1);

// Decrement
Logsnag::mutateInsight(title: 'Open Tickets', incrementBy: -1);

// Float values
Logsnag::mutateInsight(title: 'Revenue', incrementBy: 49.99, icon: '💰');
```

Or with the helper:

```
mutate_insight(title: 'API Calls', incrementBy: 1);
```

**Parameters:**

ParameterTypeDefaultDescription`title``string`*required*Metric name`incrementBy``int|float`*required*Amount to increment (negative to decrement)`icon``?string``null`Emoji icon### Identify Users

[](#identify-users)

Associate properties with a user for user-level analytics.

```
use PGT\Logsnag\Facades\Logsnag;

Logsnag::identify(userId: 'user-123', properties: [
    'name' => 'Jane Doe',
    'email' => 'jane@example.com',
    'plan' => 'enterprise',
    'company' => 'Acme Inc.',
]);
```

Or with the helper:

```
identify(userId: 'user-123', properties: [
    'name' => 'Jane Doe',
    'plan' => 'enterprise',
]);
```

**Parameters:**

ParameterTypeDefaultDescription`userId``string`*required*Unique user identifier`properties``array`*required*Key-value user propertiesMonolog Integration
-------------------

[](#monolog-integration)

Route your Laravel logs to LogSnag by adding a custom channel to `config/logging.php`:

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

    'logsnag' => [
        'driver' => 'custom',
        'via' => \PGT\Logsnag\Logger\LogsnagLogger::class,
        'level' => 'error', // Minimum log level to send
    ],
],
```

Then use it like any other log channel:

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

Log::channel('logsnag')->info('User logged in', ['user_id' => 123]);
Log::channel('logsnag')->error('Payment failed', ['order_id' => 456]);
```

You can also add it to your `stack` channel to send logs to LogSnag alongside your other drivers.

**Monolog driver behavior:**

- Uses the `logsnag.channel` config value as the LogSnag channel name
- Maps log levels to emoji icons via the `logsnag.icons` config
- Automatically enables notifications for `Error` level and above
- Appends log context as formatted JSON in the event description
- Respects the `level` setting to filter out lower-priority logs

Error Handling
--------------

[](#error-handling)

All API methods throw `PGT\Logsnag\Client\LogsnagClientException` on failure. The exception includes the HTTP response for debugging:

```
use PGT\Logsnag\Client\LogsnagClientException;
use PGT\Logsnag\Facades\Logsnag;

try {
    Logsnag::log(channel: 'app', event: 'Something');
} catch (LogsnagClientException $e) {
    // $e->getMessage() contains the error details
    // $e->response contains the HTTP response (if available)
}
```

API Reference
-------------

[](#api-reference)

This package covers the full [LogSnag API](https://docs.logsnag.com):

EndpointHTTP MethodPackage Method`/v1/log``POST``Logsnag::log()` / `logsnag()``/v1/insight``POST``Logsnag::insight()` / `insight()``/v1/insight``PATCH``Logsnag::mutateInsight()` / `mutate_insight()``/v1/identify``POST``Logsnag::identify()` / `identify()`Testing
-------

[](#testing)

```
composer test
```

Code Quality
------------

[](#code-quality)

```
# Static analysis
composer analyse

# Code formatting
composer format
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Paul Grant Truesdell, II](https://github.com/pgtruesdell)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance87

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 76.5% 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 ~183 days

Recently: every ~229 days

Total

6

Last Release

93d ago

Major Versions

1.3 → 2.02026-02-09

PHP version history (2 changes)1.0PHP ^8.1

2.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![pgtruesdell](https://avatars.githubusercontent.com/u/798421?v=4)](https://github.com/pgtruesdell "pgtruesdell (26 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")

---

Tags

laravellaravel-logsnagpgtruesdell

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/pgtruesdell-laravel-logsnag/health.svg)

```
[![Health](https://phpackages.com/badges/pgtruesdell-laravel-logsnag/health.svg)](https://phpackages.com/packages/pgtruesdell-laravel-logsnag)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[spatie/laravel-slack-alerts

Send a message to Slack

3212.6M4](/packages/spatie-laravel-slack-alerts)[keepsuit/laravel-opentelemetry

OpenTelemetry integration for laravel

142347.8k](/packages/keepsuit-laravel-opentelemetry)[spatie/laravel-error-share

Share your Laravel errors to Flare

43965.6k3](/packages/spatie-laravel-error-share)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[tapp/filament-maillog

Filament plugin to view outgoing mail

2952.6k1](/packages/tapp-filament-maillog)

PHPackages © 2026

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