PHPackages                             jplhomer/laravel-axiom - 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. jplhomer/laravel-axiom

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

jplhomer/laravel-axiom
======================

Laravel logging handler for Axiom

v1.1(2y ago)27.6k↓28.6%3[3 PRs](https://github.com/jplhomer/laravel-axiom/pulls)MITPHPPHP ^8.1CI passing

Since Jan 17Pushed 2mo ago1 watchersCompare

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

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

Laravel logging handler for Axiom
=================================

[](#laravel-logging-handler-for-axiom)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c739ed7664980c3956d2425227987e086ba4561189fcb08ea387b3ae1498081c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a706c686f6d65722f6c61726176656c2d6178696f6d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jplhomer/laravel-axiom)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7f1a131d12ac99ed57b49e54f5589fa542b20be844b9bd50d2fd4bec7b8f9683/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a706c686f6d65722f6c61726176656c2d6178696f6d2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/jplhomer/laravel-axiom/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/56050480afc1c69af29b2ef1435480181cf4d690e2dbf97ee92548e0efc62516/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a706c686f6d65722f6c61726176656c2d6178696f6d2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/jplhomer/laravel-axiom/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/f1db609ffda0484f8c8fb1d886308e1658db592882eae06a221b0f709f41d3c8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a706c686f6d65722f6c61726176656c2d6178696f6d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jplhomer/laravel-axiom)

This package provides a logging handler for [Axiom](https://axiom.co/). It allows you to send logs to Axiom from your Laravel application.

You can install the package via composer:

```
composer require jplhomer/laravel-axiom
```

Then, add a new `axiom` channel to your `config/logging.php` file:

```
$channels = [
    // ...
    'axiom' => [
        'driver' => 'monolog',
        'handler' => Jplhomer\Axiom\AxiomLogHandler::class,
        'level' => env('LOG_LEVEL', 'debug'),
        'with' => [
            'apiToken' => env('AXIOM_API_TOKEN'),
            'dataset' => env('AXIOM_DATASET'),
        ],
    ],
]
```

Finally, be sure to set your `AXIOM_API_TOKEN` and `AXIOM_DATASET` environment variables in `.env`. You can create a token in the [Axiom dashboard](https://app.axiom.co/barkpass-lxgt/settings/api-tokens).

```
LOG_CHANNEL=axiom
AXIOM_API_TOKEN=your-api-token
AXIOM_DATASET=your-dataset
```

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

[](#performance-considerations)

Since Axiom logs are sent over HTTP, you may want to consider the performance impact of sending logs during request time. By default, this package will send logs to Axiom synchronously. This means each time you log something, your application will wait for the request to Axiom to complete before continuing to process the request.

A better solution is to send structured request logs *after* the response has been sent. To accomplish this, you can create a [terminable middleware](https://laravel.com/docs/8.x/middleware#terminable-middleware) that sends the logs to Axiom after the response has been sent to the user.

```
