PHP code example of nix-logger / nix-logger-laravel
1. Go to this page and download the library: Download nix-logger/nix-logger-laravel library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nix-logger / nix-logger-laravel example snippets
// config/app.php
'providers' => [
Illuminate\Auth\AuthServiceProvider::class,
NixLogger\Laravel\NixLoggerServiceProvider::class,
]
// bootstrap/providers.php
return [
Illuminate\Auth\AuthServiceProvider::class,
NixLogger\Laravel\NixLoggerServiceProvider::class,
];
// config/app.php
'aliases' => [
'NixLogger' => NixLogger\Laravel\Facades\NixLogger::class,
]
// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
$middleware->alias([
'NixLogger' => NixLogger\Laravel\Facades\NixLogger::class,
]);
})
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'nix-logger'],
'ignore_exceptions' => false,
],
'nix-logger' => [
'driver' => 'custom',
'via' => \NixLogger\Laravel\Logger\NixLogger::class,
],
'channels' => [
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => \NixLogger\Laravel\Handlers\NixLoggerStreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
'processors' => [PsrLogMessageProcessor::class],
],
]
\NixLogger::error('Test Error');
Route::get('/error', function () {
throw new Exception('This is a test exception');
return [
'message' => 'This is a test response',
];
});
bash
php artisan tinker