PHPackages                             mattyeend/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. mattyeend/logging

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

mattyeend/logging
=================

A comprehensive logging library for Laravel applications.

v1.2.3(2mo ago)194MITPHPPHP &gt;=8.1

Since Jan 11Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/MatthewYeend/Logging)[ Packagist](https://packagist.org/packages/mattyeend/logging)[ Fund](https://www.buymeacoffee.com/mattyeend)[ GitHub Sponsors](https://github.com/MattYeend)[ RSS](/packages/mattyeend-logging/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (15)Used By (0)

Logging Package
===============

[](#logging-package)

A Laravel package for logging application events into a database table. This package provides an extensible model, a database migration, and helper methods for recording user and system actions in a structured and searchable format.

---

Features
--------

[](#features)

- **Action Logging**: Easily log predefined or custom actions with optional metadata.
- **User Relationships**: Track the user performing the action (`logged_in_user_id`) and any user related to the action (`related_to_user_id`).
- **Structured Data**: Store additional data as JSON for enhanced flexibility.
- **Predefined Actions**: Common actions like login, logout, user creation, and more are included.

---

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

[](#installation)

1. **Require the package**Run the following command: `composer require MattYeend/Logging`
2. **Publish the `log.php` model**Run `php artisan vendor:publish --tag=logging-model`
3. **Run Migrations**Run the migrations to create the `logs` table: `php artisan migrate`

Usage
-----

[](#usage)

### Log an Action

[](#log-an-action)

Use the `Log` model to log actions. The predefined constants simplify common actions

```
use App\Models\Log;

// Log a user login event
Log::log(Log::ACTION_LOGIN, ['ip' => request()->ip()], auth()->id());

```

### Log Custom Actions

[](#log-custom-actions)

You can log actions not predefined in the package: `Log::log(99, ['custom_key' => 'custom_value'], auth()->id(), $relatedUserId);`

### Model Relationships

[](#model-relationships)

Retrieve the user who performed the action or the user related to it:

```
$log = Log::find(1);

// Logged-in user
$loggedInUser = $log->loggedInUser;

// Related user
$relatedUser = $log->relatedToUser;

```

Predefined Actions
------------------

[](#predefined-actions)

ConstantValueDescription`ACTION_LOGIN`1User logged in`ACTION_LOGOUT`2User logged out`ACTION_CREATE_USER`3Created a new user`ACTION_UPDATE_USER`4Updated a user`ACTION_DELETE_USER`5Deleted a user`ACTION_SHOW_USER`6Viewed a user profile`ACTION_WELCOME_EMAIL_SENT`7Sent a welcome email`ACTION_CONFIRM_PASSWORD`8Confirmed password`ACTION_FORGOT_PASSWORD`9Initiated password reset`ACTION_REGISTER_USER`10Registered a new user`ACTION_LOGIN_FAILED`11Login failed`ACTION_LOGIN_PASSWORD_FAILED`12Login via password failed`ACTION_LOGIN_EMAIL_FAILED`13Login via email failed`ACTION_LOGIN_USERNAME_FAILED`14Login via username failed`ACTION_LOGIN_SUCCESS`15Login success`ACTION_RESET_PASSWORD`16Reset password`ACTION_RESET_EMAIL`17Reset email`ACTION_RESET_USERNAME`18Reset username`ACTION_VERIFY_USER`19Verified user email`ACTION_PASSWORD_CHANGED`20Changed password`ACTION_MFA_ENABLED`21Enabled multi-factor auth`ACTION_MFA_DISABLED`22Disabled multi-factor auth`ACTION_PROFILE_UPDATED`23Updated user profile`ACTION_EMAIL_UPDATED`24Updated email address`ACTION_ROLE_ASSIGNED`25Assigned a role to a user`ACTION_PERMISSION_GRANTED`26Granted permissions to user`ACTION_PERMISSION_REVOKED`27Revoked user permissions`ACTION_GENERAL_ERROR`28General error`ACTION_FOUR_HUNDRED_ERROR`29Four hundred error`ACTION_FIVE_HUNDRED_ERROR`30Five hundred error`ACTION_CLEAR_CACHE`31Clear CacheCustomisation
-------------

[](#customisation)

### Extend the Logger Model

[](#extend-the-logger-model)

Add additional functionality by extending the `Log` model in your application.

### Troubleshooting

[](#troubleshooting)

1. **Migration Not Found**Ensure the `LoggerServiceProvider` is loading migrations by verifying the path in: `src/LoggerServiceProvider.php`: `$this->loadMigrationsFrom(__DIR__ . '/Database/Migrations');`
2. **Data Validation Issues**Ensure `data` passed to `Log::log()` is either `null` or an array. Example: `Log::log(Log::ACTION_LOGIN, ['key' => 'value'], auth()->id());`

Testing
-------

[](#testing)

To run tests, follow the next steps:

1. Install dependencies:

```
composer install
```

2. Run the tests:

```
composer test
```

License
-------

[](#license)

This package is licensed under the MIT License.

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

[](#contributing)

Feel free to fork the repository and submit pull requests for improvements or new features!

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance86

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Recently: every ~103 days

Total

13

Last Release

66d ago

PHP version history (2 changes)v1.1.1PHP ^7.4 || ^8.0 || ^8.1 || ^8.2

v1.1.10PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/280b020ca627b367261832c86f63f9f71076d720e1f8e6c4a7ae2c9c1a77f39e?d=identicon)[MattYeend](/maintainers/MattYeend)

---

Top Contributors

[![MattYeend](https://avatars.githubusercontent.com/u/23270321?v=4)](https://github.com/MattYeend "MattYeend (19 commits)")

---

Tags

composercomposer-packagelaravellaravel-10laravel-11laravel-12laravel-13laravel-frameworklaravel-logginglaravel-migrationlaravel-packagelaravel10laravel11laravel12laravel13loglogginglogsmigrationmodellaravelloggingpackagetrackingAuditlogger

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mattyeend-logging/health.svg)

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

###  Alternatives

[bugsnag/bugsnag-laravel

Official Bugsnag notifier for Laravel applications.

90334.6M36](/packages/bugsnag-bugsnag-laravel)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)

PHPackages © 2026

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