Leff
Leff

Reputation: 1276

Laravel not logging an array into log file

I am trying to log some arrays into laravel.log file, I am trying to do so like this:

Log::info('Post: ' . $postSlug . ' with the post ID: ' . $postID .
 print_r($linkMatches[0], TRUE));

But, nothing gets logged, but if I do dd($linkMatches[0]); then I get back an array:

array:1 [
  0 => "'https://hivnorge.no/Se-hva-vi-gjoer/Underartikler/Positive-women'"
]

Why do I get back an array when I do dd, but can't log it into laravel.log file?

UPDATE

For some reason, it started working all of a sudden, no change in the code or anything else, but now it logs everything.

Upvotes: 3

Views: 4522

Answers (1)

M Usman Nadeem
M Usman Nadeem

Reputation: 415

i think the issue is print_r tag, in doc Laravel Log doc

Log::info('User failed to login.', ['id' => $user->id]);

instead of appending print_r you can pass it as param it solve your problem

Upvotes: 1

Related Questions