PHPackages                             gilbitron/laravel-canonical-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. gilbitron/laravel-canonical-logger

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

gilbitron/laravel-canonical-logger
==================================

A package to create 'canonical' logs lines for requests and queue jobs in Laravel

0.4.0(1y ago)024MITPHPPHP &gt;=8.1

Since Oct 9Pushed 1y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (5)Versions (5)Used By (0)

Laravel Canonical Logger
========================

[](#laravel-canonical-logger)

A package to create "canonical" logs lines for requests and queue jobs in Laravel. Inspired by Stripe's approach to flexible, lightweight observability, [canonical log lines](https://stripe.com/blog/canonical-log-lines) are designed to be easy to parse, filter, and analyze. Sitting somewhere between unstructured logging and full-blown tracing, canonical logs are a great way to get a lot of value out of your logs with minimal effort.

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

[](#installation)

You can install the package via composer:

```
composer require gilbitron/laravel-canonical-logger
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Gilbitron\LaravelCanonicalLogger\LaravelCanonicalLoggerServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

By default, the package will log canonical log lines for all requests and queue jobs to your application's default log channel. You can customize the log channel and log level in the config file.

For example, you should see log lines like this in your log file:

```
[2024-09-30 19:25:28] local.INFO: canonical-log-line {"type":"request","environment":"local","request_id":"cabee36d-4ab3-48f1-b250-8540a349c4bd","http_method":"GET","http_uri":"/","http_status":200,"http_response_time":0.0089,"session_id":"bYVrl7EMl0nh6N1A3CTHDxgBsWx59TmFzjekwHK2","url":"http://canonical-logger.test"}
[2024-10-09 20:57:32] local.INFO: canonical-log-line {"type":"job","environment":"local","id":"6ec632c9-75ef-4d18-acb1-485d1abc1d36","status":"processed","name":"App\\Jobs\\ExampleJob","basename":"ExampleJob","connection":"database","queue":"default","attempts":1,"request_id":"0c0c97f2-498d-4314-9c14-55382c925a9c","session_id":"bYVrl7EMl0nh6N1A3CTHDxgBsWx59TmFzjekwHK2"}
[2024-10-09 20:57:36] local.INFO: canonical-log-line {"type":"request","environment":"local","request_id":"8a89dc1d-e1be-401c-9d07-2177d923529a","http_method":"GET","http_uri":"/queue","http_status":404,"http_response_time":0.0117,"url":"http://canonical-logger.test/queue","exception_class":"Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException","exception_message":"The route queue could not be found.","exception_code":0,"exception_file":".../laravel/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php","exception_line":44}

```

You can then use your log service of choice to filter and analyze these log lines. For example, if you ingest your logs into AWS Cloudwatch, you can use [Cloudwatch Log Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html) to query and visualize your logs. Log Insights is smart enough to parse JSON log lines, so you can easily filter and aggregate your logs. [Logstash](https://www.elastic.co/logstash), [DataDog](https://www.datadoghq.com/), and [Splunk](https://www.splunk.com/) are other popular options for log analysis.

Here's an example Cloudwatch Log Insights query to get the average response time for requests:

```
fields @timestamp, @message
| filter @message like /canonical-log-line/
| filter type = 'request'
| stats avg(http_response_time) as avg_response_time by bin(1m)
| sort @timestamp desc
```

Another example might be to get the number of processed jobs per hour:

```
fields @timestamp, @message
| filter @message like /canonical-log-line/
| filter type = 'job'
| filter status = 'processed'
| stats count() as processed_jobs by bin(1h)
| sort @timestamp desc
```

Testing
-------

[](#testing)

You can run the tests with:

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

License
-------

[](#license)

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

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance40

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

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

Total

4

Last Release

511d ago

PHP version history (2 changes)0.1.0PHP &gt;=8.2

0.3.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/20011de485eeea26b5582c75daaab217937832762b5d5f551d34d07f74138bb0?d=identicon)[gilbitron](/maintainers/gilbitron)

---

Top Contributors

[![gilbitron](https://avatars.githubusercontent.com/u/203882?v=4)](https://github.com/gilbitron "gilbitron (22 commits)")

---

Tags

laravellaravel-packagelogging

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/gilbitron-laravel-canonical-logger/health.svg)

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

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

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