lancodev/laravel-logging

This is my package laravel-logging
1,202
Install
composer require lancodev/laravel-logging
Latest Version:0.7
PHP:^8.2
Laravel:11
Older releases:9 · 10
License:MIT
Last Updated:Apr 20, 2026
Links: GitHub  ·  Packagist
Maintainer: kylekanderson

Laravel Logging

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a simple way to log events to a database table. It provides a convenient Loggable Trait to allow you to link your logs to a model. It also provides a Log model that you can use to query your logs.

Installation

You can install the package via composer:

composer require lancodev/laravel-logging

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-logging-migrations"
php artisan migrate

Usage

Add the Loggable Trait to your model(s) that you want to log events for.

Then, you can create logs for the model using the logs relationship:

$model->logs()->create([
    'type' => 'Info',
    'log' => 'lorem ipsum',
]);

To view logs for a given model, you can use the logs relationship:

$model->logs;

Or use standard Eloquent query language to filter the logs by type, etc:

$model->logs()->where('type', 'Info')->get();

Lancodev\LaravelLogging\Models\Log {
  id: 1,
  loggable_type: "App\Models\{SOME_MODEL}",
  loggable_id: 1,
  type: "Info",
  log: "lorem ipsum",
  created_at: "2023-01-01 00:00:00",
  updated_at: "2023-01-01 00:00:00",
},

The Log model also has a loggable relationship that allows you to access the model that the log belongs to:

$log->loggable;****

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

designmynight/laravel-log-mailer

A package to support logging via email in Laravel

43,790 15
steadfast-collective/laravel-system-log

Provides a System Log model and helpers for contextful logging with a FilamentPH...

1,777 0
supersixtwo/dblog

Lightweight Laravel package for writing custom logs and error messages to a data...

44 3
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

644,549,754 9,698

Version History

Version Released PHP Laravel License
0.7 ^8.2 ^11.0 MIT
0.6 ^8.2 ^10.0 MIT
0.5 ^8.1 ^9.0 MIT
0.4 ^8.1 ^9.0 MIT
0.3 ^8.1 ^9.0 MIT