PHP code example of aporat / laravel-cloudwatch-logger
1. Go to this page and download the library: Download aporat/laravel-cloudwatch-logger 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/ */
aporat / laravel-cloudwatch-logger example snippets
// LineFormatter as format string
'formatter' => '%channel%: %level_name%: %message% %context% %extra%',
// Or as a class
'formatter' => Monolog\Formatter\JsonFormatter::class,
// Or as a callable
'formatter' => function (array $config) {
return new Monolog\Formatter\LineFormatter(
format: '%channel%: %level_name%: %message% %context% %extra%',
dateFormat: null,
allowInlineLineBreaks: false,
ignoreEmptyContextAndExtra: true
);
},
use Illuminate\Support\Facades\Log;
Log::info('User login', ['user_id' => 123]);