Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Padarom's avatar

ReflectionException: Class log does not exist

I have recently started working on a project that builds on the Laravel core, but expands it to fit my needs. For this, I need to extend some of the core classes (Application, Http Kernel, Exception Handler, ...)

These core files seem to be autoloading correctly and I have referenced those in bootstrap/app.php, wherever the laravel core was referenced (singleton bindings for Http Kernel, Console Kernel, Exception Handler and the application).

I don't expect it to be functional at this point, but I'd like to see if the classes I've built already work. However upon launching the webserver and accessing it I get the following exception:

Uncaught exception 'ReflectionException' with message 'Class log does not exist' in /Users/christophermuehl/Code/SurgeonBoard/board/vendor/laravel/framework/src/Illuminate/Container/Container.php:738
Stack trace:
#0 /Users/christophermuehl/Code/SurgeonBoard/board/vendor/laravel/framework/src/Illuminate/Container/Container.php(738): ReflectionClass->__construct('log')
#1 /Users/christophermuehl/Code/SurgeonBoard/board/vendor/laravel/framework/src/Illuminate/Container/Container.php(627): Illuminate\Container\Container->build('log', Array)
#2 /Users/christophermuehl/Code/SurgeonBoard/board/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('log', Array)
#3 /Users/christophermuehl/Code/SurgeonBoard/board/vendor/laravel/framework/src/Illuminate/Container/Container.php(839): Illuminate\Foundation\Application->make('Psr\\Log\\LoggerI...')
#4 /Users/christophermuehl/Code/SurgeonBoard/board/vendor/laravel/framework/src/Illuminate/Container/Container.php(802):  in <b>/Users/christophermuehl/Code/SurgeonBoard/board/vendor/laravel/framework/src/Illuminate/Container/Container.php</b> on line <b>738</b><br />

I did some debugging and found out, that \Illuminate\Container\Container build tries to instantiate a Psr\Log\LoggerInterface which somehow gets turned to the abstract log. The error itself happens during an execution of a closure on line 729. I have already tried to use a different version of the framework or use the original app.php again (with the original classes), but neither worked. I cannot figure out, how to get rid of this error.

I hope someone can point me in the right direction.

Thanks in advance!

0 likes
3 replies
bobbybouwmann's avatar

Do you use a log class somewhere? It looks like it's not finding the correct Log class

Padarom's avatar

I don't, but I can't even find out where it's trying to load one from, or where to define which class to use. I could imagine doing an $app->bind or the like somewhere, but in similar applications I haven't seen them defining their own Log class.

Padarom's avatar
Padarom
OP
Best Answer
Level 5

Took me a long while to figure this out, but I got it finally. I added some scaffolding to my own Http Kernel just so I could try it out:

class Kernel extends HttpKernel
{
  protected $bootstrappers = [ ];

  protected $middleware = [ ];

  protected $routeMiddleware = [ ]; 
}

Problem with this was, that $bootstrappersin the Foundation Http Kernel contains a configuration for the logging class (Illuminate\Foundation\Bootstrap\ConfigureLogging). I reset it to an empty array, not thinking about it. For now I just got rid of the bootstrappers, later on I will probably include it again, but explicitly specify the ConfigureLogin class.

Now with this fixed, I get a whole lot of new errors, such as unknown class AppServiceProvider. But that's the kind of error I would expect, so now I know that my kernel and the other scaffolding more or less works and I can start working on custom service providers and the rest.

Please or to participate in this conversation.