andrey-helldar/laravel-logger-channels

Set of custom loggers for Monolog in Laravel

v1.3.1 2020-12-30 19:44 UTC

This package is auto-updated.

Last update: 2024-04-16 15:20:32 UTC


README

Set of custom loggers for Monolog in Laravel.

Laravel Logger Channels

Total Downloads Latest Stable Version Latest Unstable Version

StyleCI License

Installation

To get the latest version of Laravel Logger Channels, simply require the project using Composer:

$ composer require andrey-helldar/laravel-logger-channels

This command will automatically install the latest version of the package for your environment.

Instead, you may of course manually update your require block and run composer update if you so choose:

{
    "require": {
        "andrey-helldar/laravel-logger-channels": "^1.2"
    }
}

Using

There are two methods for using custom loggers - calling a class with a settings preset or manually setting a logger.

Processes Rotation

Add a new channel in file config/logging.php or modify an existing one using one of the following methods:

use Helldar\LaravelLoggerChannels\Loggers\ProcessesRotation\DifferentLogsChannel;

return [
    'channels' => [
        'your_channel' => DifferentLogsChannel::get(
            storage_path('logs/your-filename.log')
        )
    ]
];
use Helldar\LaravelLoggerChannels\Loggers\Common\LogFormatter;
use Helldar\LaravelLoggerChannels\Loggers\ProcessesRotation\Logger;

return [
    'channels' => [
        'your_channel' => [
            'driver' => 'custom',
            'via'    => Logger::class,
            'tap'    => [LogFormatter::class],
            'path'   => storage_path('logs/your-filename.log'),
            'days'   => 7,
        ]
    ]
];

In each case, one log file will be created for one session. The session label is taken from the global variable LARAVEL_START.

image

License

This package is licensed under the MIT License.

For Enterprise

Available as part of the Tidelift Subscription.

The maintainers of andrey-helldar/laravel-logger-channels and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. Learn more.