The package provides the ability to write logs into the database synchronously or asynchronously, along with other logging channels.

Overview

Laravel database log channel

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

The package provides the ability to write logs into the database synchronously or asynchronously, along with other logging channels.

Installation

You can install the package via composer:

composer require goszowski/laravel-database-log-channel

You can publish and run the migrations with:

php artisan vendor:publish --tag="database-log-channel-migrations"
php artisan migrate

Configure logging.php:

return [
    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily', 'database'], // Add "database" channel
            'ignore_exceptions' => false,
        ],

        // ...
        'database' => [
            'driver' => 'monolog',
            'handler' => Goszowski\DatabaseLogChannel\Logging\DatabaseLogHandler::class,
            'via' => Goszowski\DatabaseLogChannel\Logging\DatabaseLogger::class,

            'alternative-log-channel' => 'daily', // Use an alternate channel when it is not possible to write to the database
            'connection' => null, // Use default connection
            'table' => 'logs',
            'async' => true, // If true, will be sent to the queue
            'queue' => 'default', // Define a queue for asynchronous logging
            'level' => 'error',
        ],

    ],
];

Usage

use Log;

Log::error('My error message');

Data Pruning

Without pruning, the logs table can accumulate records very quickly. To mitigate this, you should schedule the database-logs:prune Artisan command to run daily:

$schedule->command('database-logs:prune')->daily();

By default, all entries older than 24 hours will be pruned. You may use the hours option when calling the command to determine how long to retain Logs data. For example, the following command will delete all records created over 48 hours ago:

$schedule->command('database-logs:prune --hours=48')->daily();

Changelog

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

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.

You might also like...
A horrendous PM plugin to manually load all the chunks in your world without logging on. Only for the sole purpose of aiding in PM4 - DF world conversion.

ChunkLoader A horrendous PM plugin to manually load all the chunks in your world without logging on. Only for the sole purpose of aiding in PM4 - DF

PocketMine-MP To Discord Chat Logging.
PocketMine-MP To Discord Chat Logging.

Welcome To PocketCord PocketCord is a PocketMine-MP plugin designed to link discord and your PocketMine-MP Server with quick and easy setup! Installat

Magento 2 Italian Language Pack is special gift for Magento 2 Community Edition. The data of the translation is supplied by Magento 2 Translation Project of Crowdin site, on which you will contribute into the project and download the zip file to install on your own store. This knowledge base will include full of the clear guides that supports you to convert the default language (English) into Italian language on your entire store.
Easily add logs anywhere in your Magento 2 code

Magento 2 Simple Log Easily add logs anywhere in the code (like Magento 1). Requirements Requires Magento 2 in any version. Installation Add the Log.p

Tango is a command-line tool for analyzing access logs 💃
Tango is a command-line tool for analyzing access logs 💃

Tango Tool to get insights from the server access logs Tango is a dependency-free command-line tool for analyzing access logs 💃 Currently, work on th

Unterstützung bei der DSGVO-konformen Umsetzung von ein oder mehreren REDAXO-Websites, indem Logs und Daten nach festgelegten Regeln gelöscht werden.
Unterstützung bei der DSGVO-konformen Umsetzung von ein oder mehreren REDAXO-Websites, indem Logs und Daten nach festgelegten Regeln gelöscht werden.

Auto-Delete-Addon für REDAXO 5.x Löscht alte Logs und Datensätze via Cronjob. Features YForm-Feld datestamp_auto_delete Ein Feld für YForm, das wie da

This package provides a simple and intuitive way to work on the Youtube Data API. It provides fluent interface to Youtube features.

Laravel Youtube Client This package provides a simple and intuitive way to work on the Youtube Data API. It provides fluent interface to Youtube featu

The MX_PhinxMigrations module integrates Phinx database migrations into Magento 2

MX Phinx Migrations About The MX_PhinxMigrations module integrates Phinx database migrations into Magento 2 as a replacement for the built-in setup:up

Stackdriver Monitoring provides visibility into the performance, uptime, and overall health of cloud-powered applications.

Stackdriver Monitoring API documentation NOTE: This repository is part of Google Cloud PHP. Any support requests, bug reports, or development contribu

Releases(v2.0.0)
Owner
Jarosław Goszowski
PHP, Laravel developer, Runsite LLC Owner
Jarosław Goszowski
This is an experiment to export all RFCs from the PHP wiki into Git, including the change history for each RFC (along with the date and author of each change). This is not meant to replace the wiki.

PHP Requests for Comments (RFCs) About This repository is an experiment to export all RFCs from the PHP wiki into Git, including the change history fo

Ben Ramsey 34 Jun 20, 2022
Easily run code asynchronously

Asynchronous and parallel PHP This library provides a small and easy wrapper around PHP's PCNTL extension. It allows running of different processes in

Spatie 2.3k Jan 7, 2023
Result of our code-along meetup writing PHP 8.1 code

PHP 8.1 Demo Code This code demonstrates various PHP 8.0 and 8.1 features in a realistic, functional (but incomplete) codebase. The code is part of so

azPHP 2 Nov 14, 2021
Revived of weareblahs/unifi-tv. Watch free channels by unifi TV on any 3rd party IPTV players that support MPEG-DASH + Widevine!

unifi-tv-revived Revived of weareblahs/unifi-tv. Watch free channels by unifi TV on any 3rd party IPTV players that support MPEG-DASH + Widevine! What

Sam Sam 6 Jun 14, 2022
This packages enables the ability to serve file streams in a smart way

A blade component for easy image manipulation Want to serve private hosted images without the need to code your own logic ? Want to resize your images

Dieter Coopman 205 Dec 19, 2022
Moodle ReactJS - gives you ability to use ReactJS inside any moodle page.

moodle-local_reactjs Moodle ReactJS - gives you ability to use ReactJS inside any moodle page. Note for devs: You'll need to set up npm dependencies d

SmartApp 5 Dec 14, 2022
A class to help convert bytes into other units (kb, mb, etc).

A class to help convert bytes into other units (kb, mb, etc). This package can be used to convert int|float values from bytes to KB, MB and GB as well

Ryan Chandler 12 Mar 15, 2022
Here is an Instagram Guest API. Gather all public information as JSON format without logging yourself.

Here is an Instagram Guest API. Gather all public information as JSON format without logging yourself. It's all automation and time saving.

Quatrecentquatre 1 Nov 2, 2021
A PocketMine-MP plugin for logging Exceptions to a Sentry server

Sentry A PocketMine-MP plugin for logging Exceptions to a Sentry server. Asynchronous logging If you want to log exceptions in a thread-safe way, you

null 4 Apr 9, 2022