2017 © Pedro Peláez
 

library laravel-custom-log

Laravel Custom Log

image

imtigger/laravel-custom-log

Laravel Custom Log

  • Friday, July 6, 2018
  • by imtigger
  • Repository
  • 1 Watchers
  • 0 Stars
  • 94 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Laravel CustomLog

Laravel failsafe custom logging library, (*1)

  • Log to multiple destinations
  • Log to Console (STDOUT)
  • Log to File
  • Log to MySQL
  • Log to Redis
  • Log to syslog (Local/Remote)
  • Log to Graylog (TCP/UDP)
  • (Optional) Failsafe (Don't throw any exceptions in case logger fails)
  • (Optional) Replace Laravel log (Laravel <= 5.5)
  • (Optional) Register as Laravel logger channel (Laravel >= 5.6)

Installation

composer require imtigger/laravel-custom-log, (*2)

On Laravel 5.4 and below, add the ServiceProvider to your config/app.php, (*3)

Imtigger\LaravelCustomLog\LaravelCustomLogServiceProvider::class, (*4)

Publish Config, (*5)

php artisan vendor:publish --provider="Imtigger\\LaravelCustomLog\\LaravelCustomLogServiceProvider" --tag=config, (*6)

Publish MySQL Migration (Optional, for Log to MySQL), (*7)

php artisan vendor:publish --provider="Imtigger\\LaravelCustomLog\\LaravelCustomLogServiceProvider" --tag=migration, (*8)

Choose Log Destinations

Add config into .env, you may enable multiple destinations, (*9)

Console (STDOUT)

  • CUSTOM_LOG_CONSOLE_ENABLE (true|false, default=false)

File

  • CUSTOM_LOG_FILE_ENABLE (true|false, default=true)

MySQL

  • CUSTOM_LOG_MYSQL_ENABLE (true|false, default=false)
  • DB_LOG_CONNECTION (connection defined in database.php, default=mysql)
  • DB_LOG_TABLE (default=logs)

Redis

  • CUSTOM_LOG_REDIS_ENABLE (true|false, default=false)
  • REDIS_LOG_CONNECTION (connection defined in cache.php, default=default)
  • REDIS_LOG_KEY

Syslog

  • CUSTOM_LOG_SYSLOG_ENABLE (true|false, default=false)
  • CUSTOM_LOG_SYSLOG_HOST
  • CUSTOM_LOG_SYSLOG_PORT (default=514)

Gelf (Graylog)

  • CUSTOM_LOG_GELF_ENABLE (true|false, default=false)
  • CUSTOM_LOG_GELF_PROTOCOL (TCP|UDP, default=UDP)
  • CUSTOM_LOG_GELF_HOST
  • CUSTOM_LOG_GELF_PORT (default=12201)

Basic Usage

CustomLog::emergency($channel, $message, $context), (*10)

CustomLog::alert($channel, $message, $context), (*11)

CustomLog::critical($channel, $message, $context), (*12)

CustomLog::error($channel, $message, $context), (*13)

CustomLog::warning($channel, $message, $context), (*14)

CustomLog::notice($channel, $message, $context), (*15)

CustomLog::info($channel, $message, $context), (*16)

CustomLog::debug($channel, $message, $context), (*17)

CustomLog::log($level, $channel, $message, $context), (*18)

Replace Laravel log (Laravel <= 5.5)

Edit your bootstrap/app.php, add this before returning the application, (*19)

$app->configureMonologUsing(function ($monolog) {
    $monolog->pushHandler(Imtigger\LaravelCustomLog\CustomLog::getSystemHandler());
});

Register as Laravel logger channel (Laravel >= 5.6)

Edit your config/logging.php, add this to the channels array, (*20)

'customlog' => [
    'driver' => 'custom',
    'via' => Imtigger\LaravelCustomLog\CustomLog::class,
]

The Versions

06/07 2018

dev-master

9999999-dev

Laravel Custom Log

  Sources   Download

MIT

The Requires

 

by Avatar Tiger

06/07 2018

0.1.2

0.1.2.0

Laravel Custom Log

  Sources   Download

MIT

The Requires

 

by Avatar Tiger

06/07 2018

0.1.1

0.1.1.0

Laravel Custom Log

  Sources   Download

MIT

The Requires

 

by Avatar Tiger

06/07 2018

0.1

0.1.0.0

Laravel Custom Log

  Sources   Download

MIT

The Requires

 

by Avatar Tiger