【发布时间】:2016-11-27 15:09:16
【问题描述】:
我正在执行一个 try catch 语句,我需要代码来执行某些操作,如果它未能捕获错误,请将其记录到 laravel 日志文件并继续循环。我的代码是:
foreach ($logins as $login) {
try {
// Do something here
} catch (Exception $e) {
// Log errors
\Log::error( $e->getMessage() );
continue;
}
}
但我收到一个错误,显示为
[Symfony\Component\Debug\Exception\FatalErrorException]
Namespace declaration statement has to be the very first statement in the script
我在名称空间中使用了 \Log:: 并尝试添加 use Log;,但我仍然收到此错误。
【问题讨论】:
标签: php logging error-handling try-catch laravel-5.2