laravel-cloudwatch-logs
laravel-cloudwatch-logs copied to clipboard
Symfony\Component\ErrorHandler\Error\FatalError: Declaration of Maxbanton\Cwh\Handler\CloudWatch::write(array $record): void must be compatible with Monolog\Handler\AbstractProcessingHandler::write(Monolog\LogRecord $record): void in file /maxbanton/cwh/src/Handler/CloudWatch.php on line 164
"laravel/framework": "v10.19.0" "pagevamp/laravel-cloudwatch-logs":"v1.1.1", "monolog/monolog": "3.4.0",
I added in logging.php 'cloudwatch' => [ 'driver' => 'custom', 'name' => env('CLOUDWATCH_LOG_NAME', ''), 'region' => env('CLOUDWATCH_LOG_REGION', ''), 'credentials' => [ 'key' => env('CLOUDWATCH_LOG_KEY', ''), 'secret' => env('CLOUDWATCH_LOG_SECRET', '') ], 'stream_name' => env('CLOUDWATCH_LOG_STREAM_NAME', 'laravel_app'), 'retention' => env('CLOUDWATCH_LOG_RETENTION_DAYS', 14), 'group_name' => env('CLOUDWATCH_LOG_GROUP_NAME', 'laravel_app'), 'version' => env('CLOUDWATCH_LOG_VERSION', 'latest'), 'formatter' => \Monolog\Formatter\JsonFormatter::class, 'batch_size' => env('CLOUDWATCH_LOG_BATCH_SIZE', 10000), 'via' => \Pagevamp\Logger::class, ],
The option 'via' causes to get the error when i run a simple log Symfony\Component\ErrorHandler\Error\FatalError: Declaration of Maxbanton\Cwh\Handler\CloudWatch::write(array $record): void must be compatible with Monolog\Handler\AbstractProcessingHandler::write(Monolog\LogRecord $record): void in file /maxbanton/cwh/src/Handler/CloudWatch.php on line 164
I found that the monolog/monolog version need to be under 3.0.0 to make it works. But laravel/framework v10 requires monolog version to be upper than 3.0.
how can we solve this issue please?
FYI the maxbanton/cwh
package has been abandoned. I've created a fork phpnexus/cwh and upgraded it to work with monolog/monolog
v3 and PHP 8.1.
Simply replace maxbanton/cwh
with phpnexus/cwh
in the composer.json
file, and Maxbanton\Cwh
with PhpNexus\Cwh
in your code.
Then you'll be able to upgrade monolog/monolog
to v3 and laravel/framework
to v10.