PHPackages                             alexmacarthur/laravel-loki-logging - 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. alexmacarthur/laravel-loki-logging

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

alexmacarthur/laravel-loki-logging
==================================

Send your Laravel logs to a Grafana Loki server.

0.0.2(9mo ago)42.5k↓40.9%1MITPHPPHP ^8.1

Since Aug 6Pushed 9mo agoCompare

[ Source](https://github.com/alexmacarthur/laravel-loki-logging)[ Packagist](https://packagist.org/packages/alexmacarthur/laravel-loki-logging)[ RSS](/packages/alexmacarthur-laravel-loki-logging/feed)WikiDiscussions master Synced 1mo ago

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

Laravel Loki Logging
====================

[](#laravel-loki-logging)

A package for sending your logs to a [Grafana Loki](https://grafana.com/oss/loki/) server. Set it up, schedule a recurring job, and each log will be batched and sent asynchronously as your application runs.

Installation and Setup
----------------------

[](#installation-and-setup)

1. Install the package by running `composer require alexmacarthur/laravel-loki-logging`.
2. Publish the configuration file:

```
php artisan vendor:publish --provider=AlexMacArthur\\LaravelLokiLogging\\L3ServiceProvider

```

3. Create a new log channel in your `config/logging.php` file:

```
   'loki' => [
     'driver' => 'monolog',
     'handler' => \AlexMacArthur\LaravelLokiLogging\L3Logger::class,
   ]
```

4. Configure at least a `LOG_CHANNEL` environment variable to use the channel you created in the previous step. [See more available environment variables](#environment-variables) below.
5. Configure the `loki:persist` job to run at a regular interval. Unless there's reason to do otherwise, every minute is a good start.

```
Schedule::command('loki:persist')->everyMinute()->withoutOverlapping();

// Or using the class directly...

use AlexMacArthur\LaravelLokiLogging\L3Persister;

Schedule::command(L3Persister::class)->everyMinute()->withoutOverlapping();
```

6. `Log::info('Start logging!');`

Environment Variables
---------------------

[](#environment-variables)

By default, the following environment variables are used for logging.

NameDescription`LOG_CHANNEL`Required. Must be set to 'loki', or whatever you named the channel added to your `logging.php` configuration.`LOG_SERVER`Required. The Loki server to which logs are sent.`LOG_USERNAME`Optional. The username for basic authentication.`LOG_PASSWORD`Optional. The password for basic authentication.`LOG_APP`Optional. Used for the `application` label on every log. Falls back to `APP_NAME`.`LOG_FORMAT`Optional. The format used for each log message. The `level_name` and `message` variables can be used to build the format. By default, it's `[{level_name}] {message}`Configuration
-------------

[](#configuration)

The following configuration properties are used when forming and sending logs:

KeyDescription`context`Values to be assigned as labels in the message, used to organize and index logs by Grafana. [Read more about labels here](https://grafana.com/docs/loki/latest/get-started/labels/). Defaults are set at a configuration level, but individual values can be overridden by using the second parameter of Laravel's logging interface: `Log::info('my log', ['application' => 'override']);``format`How log messages should be formatted. [Variable substitutions](#variable-substitution) are available.`loki.server`The Loki server where data should be sent.`loki.username`Username for HTTP basic authentication. Defaults to empty.`loki.password`Password for HTTP basic authentication. Defaults to empty.Variable Substitution
---------------------

[](#variable-substitution)

All tags and log messages can be enhanced with variable names [provided by Monolog](https://github.com/Seldaek/monolog/blob/main/src/Monolog/LogRecord.php#L106):

- message
- context
- level
- level\_name
- channel
- datetime
- extra

To use them, wrap them in curly braces:

```
'format' => 'My log level is: {level_name}, and my message is: {message}',
```

Authentication
--------------

[](#authentication)

[Loki does not provide any authentication](https://grafana.com/docs/loki/latest/operations/authentication/) out of the box, but it's highly recommended to configure via reverse proxy. This package only supports Basic Auth. If you place your server behind nginx, this can be [set up here](https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication).

Shout-Out
---------

[](#shout-out)

This package was originally forked from @devcake-deventer's [laravel-loki-logging](https://github.com/devcake-deventer/laravel-loki-logging) package. Thank you for the great starting point!

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance57

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 54.2% 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 ~0 days

Total

2

Last Release

286d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/99339e7bbaeafb1098e225d87a926ccb0e7e9c47320f396c1beb828653389be4?d=identicon)[alexmacarthur](/maintainers/alexmacarthur)

---

Top Contributors

[![alexmacarthur](https://avatars.githubusercontent.com/u/8398220?v=4)](https://github.com/alexmacarthur "alexmacarthur (13 commits)")[![rdemorais](https://avatars.githubusercontent.com/u/4343744?v=4)](https://github.com/rdemorais "rdemorais (8 commits)")[![CerebralFart](https://avatars.githubusercontent.com/u/11133931?v=4)](https://github.com/CerebralFart "CerebralFart (3 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/alexmacarthur-laravel-loki-logging/health.svg)

```
[![Health](https://phpackages.com/badges/alexmacarthur-laravel-loki-logging/health.svg)](https://phpackages.com/packages/alexmacarthur-laravel-loki-logging)
```

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[honeybadger-io/honeybadger-laravel

Honeybadger Laravel integration

431.2M](/packages/honeybadger-io-honeybadger-laravel)[jackiedo/log-reader

An easy log reader and management tool for Laravel

151376.5k4](/packages/jackiedo-log-reader)

PHPackages © 2026

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