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

Multiple JSONs in one message #29

Closed wadimsewo closed 3 years ago

wadimsewo commented 3 years ago

Hi,

sometimes the JSON messages are wrapped in one message. So the extractor can extract only the first JSON and not the rest. The search for the messages is no longer possible.

It then looks like this:

{
   "version":"1.0",
   "host":"hu-srv-web01",
   "short_message":"No news notifications to be sent - continuing",
   "level":6,
   "timestamp":1616021766.570789,
   "facility":"production",
   "_process":"notification"
}{
   "version":"1.0",
   "host":"hu-srv-web01",
   "short_message":"No news notifications to be sent - continuing",
   "level":6,
   "timestamp":1616021823.716051,
   "facility":"production",
   "_process":"v3_notification",
   "_job":"App\\Jobs\\V3AllSendNewsNotificationSmartKisJob"
}

What can be the reason for this?

hedii commented 3 years ago

Hi, sorry but i don't understand what you mean.

Can you provide a complete example of what you are logging, the call to the log function in your code (with variables values), and the complete message received by graylog?

wadimsewo commented 3 years ago

Thanks for your reply.

So this is our code:

Log::info("Received {$customersCount} customers from the API. Chunking.", [
    'process' => LogProcessConfig::API
]);

Log::info("Skipped {$this->skipped} customers", [
    'process' => LogProcessConfig::API
]);
$this->consoleInfo("Updated {$this->skipped} customers");

Log::info("Updated {$this->updated} existing customers", [
    'process' => LogProcessConfig::API
]);
$this->consoleInfo("Updated {$this->updated} existing customers");

Log::info("Created {$this->created} new customers", [
    'process' => LogProcessConfig::API
]);

And these are the JSONs that were stored in one message (and not in several, as it should be):

{"version":"1.0","host":"hu-srv-web01","short_message":"Received 26 customers from the API. Chunking.","level":6,"timestamp":1616022040.849685,"facility":"production","_process":"api"}
{"version":"1.0","host":"hu-srv-web01","short_message":"Skipped 0 customers","level":6,"timestamp":1616022041.059218,"facility":"production","_process":"api"}
{"version":"1.0","host":"hu-srv-web01","short_message":"Updated 26 existing customers","level":6,"timestamp":1616022041.059414,"facility":"production","_process":"api"}
{"version":"1.0","host":"hu-srv-web01","short_message":"Created 0 new customers","level":6,"timestamp":1616022041.059513,"facility":"production","_process":"api"}

The extractor recognizes only the first JSON and then extracts it. The rest remains in raw format.

hedii commented 3 years ago

1- Please paste your entire config/logging.php file (and related environment variables if any)

2- Where does Received 26 customers from the API. Chunking. come from? I don't see it in your code.

3- Please paste the content of consoleInfo() method if it has anything to do with logging.

3- Verify that you have the same problem after running a composer update command. Maybe a bug on the dependency packages.

4- Verify that your call to Log is calling \Illuminate\Support\Facades\Log or \Log.

hedii commented 3 years ago

No answer, I am closing. Open a new issue if you have any news.