fluent-logger-php icon indicating copy to clipboard operation
fluent-logger-php copied to clipboard

WARNING: Trying to access array offset on value of type null

Open marcodefelice opened this issue 3 years ago • 5 comments

When submit a new request to a offline fluent server, got an exception but that exception never show an error message becouse on file vendor/fluent/logger/src/FluentLogger.php:328 the function $errors = error_get_last(); doesn't work and the array is NULL

i think is better to fix and show the right error message

just now i've fixed with if(empty($errors)) { $errors['message'] = "Unable to connect to the server"; }

if ok i will commit the fix

marcodefelice avatar Aug 12 '22 11:08 marcodefelice

I experienced this too, and found that it was already fixed by this commit in 2020: https://github.com/fluent/fluent-logger-php/commit/625410fc62b408d1b5d2b06b6c115f5faf6db2b8

However, there hasn't been a tagged release of this project since v1.0.1 in 2017.

If a new release gets tagged, this will be fixed.

Pinging the maintainers listed in composer.json: @chobie @sotarok @DQNEO

mstenta avatar Oct 26 '22 13:10 mstenta

Any updates on releasing a new version?

NScodeCS avatar Jul 18 '23 21:07 NScodeCS

Sorry for the long absence. Sadly, current maintainers are no longer active in this repo. Would any of you like to be new maintainer of this repo ?

DQNEO avatar Jul 19 '23 05:07 DQNEO

@DQNEO I will kindly decline.

NScodeCS avatar Jul 20 '23 15:07 NScodeCS

I trace this error with xdebug and I found that it try tcp by default and it not support udp, and the fluentd syslog input is set on udp by default. So for using udp I go for monolog SyslogUdpHandler and tried this config and it worked for me. add this config to logging channels :

'fluent' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => \Monolog\Handler\SyslogUdpHandler::class,
            'handler_with' => [
                'host' => env("FLUENTD_HOST"),
                'port' => env("FLUENTD_PORT"),
                'rfc' => \Monolog\Handler\SyslogUdpHandler::RFC3164 , 
                'ident' => 'laravel', //tag
                //'facility' => LOG_LOCAL0   //default => LOG_USER       ( this specify the second word after period in tag)
            ],
            'formatter' => \Monolog\Formatter\JsonFormatter::class,
        ]

m-ostadi avatar Apr 13 '24 12:04 m-ostadi