hedii / laravel-gelf-logger

A package to send gelf logs to a gelf compatible backend like graylog
MIT License
125 stars 33 forks source link

Unable to send logs to Graylog #30

Closed dannielmags closed 3 years ago

dannielmags commented 3 years ago

I'm still unable to send logs to Graylog with my Setup, please help :'(

logging.php

    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['single', 'gelf'],
            'ignore_exceptions' => false,
        ],

        'gelf' => [
            'driver' => 'custom',
            'via' => \Hedii\LaravelGelfLogger\GelfLoggerFactory::class,
            'level' => env('LOG_LEVEL', 'debug'),
            'name' => 'my-custom-name',
            'transport' => 'http',
            'host' => '0.0.0.0',
            'port' => 12201,
        ]

Controller to send Log

        $request = new Request([
            'version' => '1.1',
            'host' => '127.0.0.1',
            'short_message' => 'mama mo skkkrt',
            'level' => 1,
        ]);

        Log::channel('gelf')->debug('s', $request->all());

Thanks in advance :D

hedii commented 3 years ago

Your graylog server is accessible at http://0.0.0.0:12201/gelf without being logged in to graylog?

hedii commented 3 years ago

Try sending a message from a terminal:

curl -X POST -H 'Content-Type: application/json' -d '{ "version": "1.1", "host": "example.org", "short_message": "A short message", "level": 5, "_some_info": "foo" }' 0.0.0.0:12201/gelf

Go to your graylog instance, and check if your configured http input has received the message.

It should look like this (if that's not the case, you have misconfigured graylog, and i cannot help you with that):

Capture d’écran 2021-03-25 à 10 51 28 Capture d’écran 2021-03-25 à 10 53 19
dannielmags commented 3 years ago

Thanks for the help @hedii :D we just solve the problem, The gelf is not working with LaravelSail. We just tried it using a clean project pulling from a composer, and it works smoothly. :D Thank you