[英]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: 我试图将一些数组记录到laravel.log文件中,我试图这样做:
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]);
但是,什么都没有记录,但是如果我做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? 为什么在执行dd时却返回一个数组,但无法将其记录到laravel.log文件中?
UPDATE 更新
For some reason, it started working all of a sudden, no change in the code or anything else, but now it logs everything. 由于某种原因,它突然开始工作,无需更改代码或其他任何内容,但是现在它记录了所有内容。
i think the issue is print_r tag, in doc Laravel Log doc 我认为问题是print_r标签,在文档Laravel日志文档中
Log::info('User failed to login.', ['id' => $user->id]);
instead of appending print_r you can pass it as param it solve your problem 而不是附加print_r,您可以将其作为参数传递,它可以解决您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.