Uncaught ReflectionException: Class log does not exist Laravel 5.2

Uncaught ReflectionException: Class log does not exist Laravel 5.2

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Uncaught ReflectionException: Class log does not exist in Laravel 5.2

When cloning a Laravel 5.2 project from GitHub and running composer install, you might encounter a stack trace that halts execution immediately:

PHP Fatal error:  Uncaught ReflectionException: Class log does not exist in /var/www/html/Acme/vendor/laravel/framework/src/Illuminate/Container/Container.php:736

This error occurs because the Laravel container attempts to resolve a dependency named 'log', but the service definition for that class is missing. In Laravel 5.2, the logging system relies on a specific driver being registered in the configuration file. If the config/logging.php (or config/log.php in older versions) lacks the necessary bindings, the container cannot instantiate the logger, resulting in this exception.

The stack trace clearly points to the Container trying to build the 'log' service. Laravel 5.2 expects a class alias or a concrete implementation to be bound for this key. When you see Class log does not exist, it usually means the configuration file is either empty, malformed, or missing the required driver registration entirely.

Inspecting the Configuration

The most direct fix involves verifying your logging configuration. In Laravel 5.2, the default setup typically resides in config/log.php. You need to ensure that a valid driver is defined. A standard configuration for Laravel 5.2 looks like this:

return [
    'driver' => 'single',
    'path'   => storage_path('logs/laravel.log'),
    'level'  => 'debug',
    'size'   => 1024 * 256,
    'days'   => 7,
];

If your config/log.php file is empty or contains only whitespace, the container cannot find the class. Even if you replaced your .env file with a fresh example.env, the PHP configuration files remain on the server. Ensure that the log.php file exists in the app/config directory and contains valid syntax.

Environment Variables and Drivers

While the .env file controls runtime values, it does not define the core class bindings required by the container. However, the driver name specified in config/log.php must match an available implementation. In Laravel 5.2, common drivers include 'single', 'stack', and 'daily'.

If your project requires a specific driver like logstash or syslog, that class must be installed via Composer. If the configuration specifies 'driver' => 'logstash' but the vlucas/phpdotenv or similar packages aren't loaded, or if the driver hasn't been added to config/logging.php (the newer name used in later versions), the container will fail.

Check your composer.json to ensure that any logging-related dependencies are present. Sometimes, cloning a repository might result in incomplete vendor folders if git-lfs files were not fetched, though this is less common with standard PHP packages. Running composer install should restore these, but verify that the vendor directory contains the necessary drivers if you are using non-standard ones.

Configuration vs. Code

It is important to distinguish between environment variables and application configuration. The error message specifically references a missing class in the container. This implies that the PHP code expecting the logger cannot find it.

If you are moving from an initial build environment to a cloned server, ensure that the app/config/log.php file has not been overwritten by a blank template or is missing its content due to a filesystem permission issue. Check the file permissions on storage/logs/ as well; while this usually causes write failures later, ensuring the directory exists and is writable is part of a healthy setup.

Finally, if you have custom service providers that register the logger, verify that they are being loaded. In Laravel 5.2, service providers are autoloaded from the app/providers directory. If a provider responsible for binding the logger is missing or not included in the config/app.php file's providers array, the container will not know how to resolve the 'log' key.

By ensuring that config/log.php defines a valid driver and that your service providers are correctly registered, you restore the container's ability to resolve the logger, resolving the ReflectionException.

Our network