Laravel 5 Class Log Could not be Found

2019-06-19 08:54发布

问题:

I am elbows deep in Laravel 5 and it's proving to be quite the bugger with the lack of autoloading. I am running into the weirdest of errors. I can't Log anything on my localhost. If it's a PHP error, it logs just fine, but if I try to write to the log, it throws an error. It's a Windows so no File Permission errors. Here's the error I get:

[2015-02-11 20:09:40] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'App\Http\Controllers\Log' not found' in C:\xampp\htdocs\bg_checks\laravel\app\Http\Controllers\BgInfoController.php:44
Stack trace:
#0 C:\xampp\htdocs\bg_checks\laravel\storage\framework\compiled.php(1721): Illuminate\Foundation\Bootstrap\HandleExceptions->fatalExceptionFromError(Array)
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()

Laravel 5 is still pretty new so there's not a lot of info on it. I've tried to find something and can only find a forum on Laracast's forum and nothing they suggested worked.

Help!

回答1:

I don't think you have a Log class file in App\Http\Controllers directory. So you must add

use Log;

if you are using Laravel's logger, or

use Path\To\Your\Log;

for a custom logger.