PHPackages                             dotburo/laravel-molog - 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. dotburo/laravel-molog

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

dotburo/laravel-molog
=====================

Laravel tool to log model-specific messages and metrics

1.6.0(2y ago)0121GPL-3.0-or-laterPHPPHP ^7.4 || ^8

Since Oct 19Pushed 2y ago1 watchersCompare

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

READMEChangelogDependencies (11)Versions (42)Used By (0)

Molog for Laravel
=================

[](#molog-for-laravel)

[![GitHub Workflow Status](https://camo.githubusercontent.com/47a8ed5fb16fa16632a44b7e1c6831a3beeaf25797fb6cfdccd14ec9aad5256b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f646f746275726f2f6c61726176656c2d6d6f6c6f672f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473267374796c653d666c61742d737175617265)](https://github.com/dotburo/laravel-molog/actions/workflows/run-tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/d88661044a1f3a63adf86a0cf78ab6a0d6547ed95f3b5ffdee1d915b2f8071bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646f746275726f2f6c61726176656c2d6d6f6c6f672e7376673f7374796c653d666c61742d737175617265266c6162656c3d56657273696f6e)](https://packagist.org/packages/dotburo/laravel-molog)[![Total Downloads](https://camo.githubusercontent.com/1ee8a76542376d2f3818bc82fd81ea497d123b2934e04776b9fe4372fc3411a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646f746275726f2f6c61726176656c2d6d6f6c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dotburo/laravel-molog)

Laravel Molog enables you to log messages and store metrics that are related to specific models. Akin to Spatie's [Activity Log](https://github.com/spatie/laravel-activitylog), but slightly more generic and with the possibility to associate metrics (Gauges) to messages or to any other Laravel model. The gauges factory class also provides builtin timer, incrementation and percentage methods.

In its simplest form:

```
$user = auth()->user();

$this->message('Mail sent!')->concerning($user)->save();
```

A slightly more advanced example — a message with metrics for a custom model:

```
$model = new Model();

$this->gauges()->startTimer();

$this->message()->notice('Import started...')->concerning($model)->save();

// processing...

$this->gauges()
    ->concerning($this->messages()->last())
    ->gauge('Files accepted', 16)
    ->gauge('Files refused', 2)
    ->stopTimer()
    ->save();
```

Good old exception logging:

```
$msg = $this->message(new Exception('Oops'))->setContext('example');

echo $msg;              // 2023-04-10 17:34:22.348 [debug] [example] Oops
echo $msg->subject;     // Oops
echo $msg->body;        // Stack trace ...
```

Features
--------

[](#features)

- Attach log messages and metrics (gauges) to models
- Follows the PSR-3: Logger Interface
- Exception logging
- Start &amp; stop timer metrics
- Increment and decrement methods for gauges
- Output messages and metrics to string
- Generic HTTP controller

Usage
-----

[](#usage)

Install with composer from [packagist.org](https://packagist.org/packages/dotburo/laravel-molog):

```
composer require dotburo/laravel-molog
```

Publish the config file and migrations and migrate your app:

```
php artisan vendor:publish --provider="Dotburo\Molog\MologServiceProvider"

php artisan migrate
```

Wherever you need logging, use the `Logging` trait. See the documentation for more [usage examples](./doc/Examples.md).

```
class YourClass {

    use \Dotburo\Molog\Traits\Logging;

    protected function handle()
    {
        // This will store three messages
        $this->messages()
            ->message('Import process initiated', \Psr\Log\LogLevel::INFO)
            ->notice('Import process ongoing')
            ->warn('Import process aborted')
            ->save();

       // This will store one message with the subject 'aborted' and level critical
       $this->message()
            ->setContext('Import process')
            ->notice('ongoing')
            ->warn('aborted')
            ->setLevel(\Dotburo\Molog\MologConstants::CRITICAL)
            ->save();

        // Associate all subsequent metrics with the last message
        $this->gauges()->concerning($this->messages()->last());

        // Associate this metric of type INT with the first message
        $this->gauge('density', 5)->concerning($this->messages()->first())->save();

        // Add three metrics associated with the last message
        $this->gauges()
            ->gauge('density', 5.3567)  // updates the previous 'density' metric to the FLOAT value
            ->gauge('pressure', 2.35, 'bar', \Dotburo\Molog\MologConstants::GAUGE_INT_TYPE) // forcibly cast to FLOAT
            ->gauge('quality', 3)
            ->save();
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

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

[](#contributing)

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

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [dotburo](https://github.com/dotburo)
- [All Contributors](../../contributors)

License
-------

[](#license)

GNU General Public License (GPL). Please see the [license file](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Recently: every ~5 days

Total

40

Last Release

1065d ago

Major Versions

0.10.0 → 1.0.02023-04-14

PHP version history (2 changes)0.0.2PHP ^7.4

1.0.0PHP ^7.4 || ^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b8ed2843e909fe0239c457f77f851ae07cfe022efe7e48c50e3166bf70da4fd?d=identicon)[pecuchet](/maintainers/pecuchet)

---

Top Contributors

[![pecuchet](https://avatars.githubusercontent.com/u/10818207?v=4)](https://github.com/pecuchet "pecuchet (132 commits)")

---

Tags

laravelloggingdotburomertics

###  Code Quality

TestsPest

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dotburo-laravel-molog/health.svg)

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

###  Alternatives

[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)[melihovv/laravel-log-viewer

A Laravel log viewer

1231.5k1](/packages/melihovv-laravel-log-viewer)

PHPackages © 2026

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