Log file is not being written in Laravel 5.5
If your application throws an exception and displays the default exception page, but no corresponding entry appears in your storage/logs/laravel.log, you are likely dealing with a change in how Laravel handles logging based on the environment or the specific log driver configuration. In Laravel 5.5, the default behavior relies heavily on the APP_ENV variable rather than just checking if logging is enabled by default.
When you set 'log' => env('APP_LOG', 'single') in config/app.php, you are telling Laravel to look for an APP_LOG environment variable. However, simply defining APP_LOG_LEVEL=debug in your .env file does not automatically force the log driver to write to a file if the primary environment setting suggests otherwise.
The most common reason logs vanish while storage operations (like using the Storage facade) continue to work is that your application is running in an environment where Laravel expects logs to be handled by a different driver, or the path resolution for the single log file has changed. In many production setups, developers switch from the default 'single' driver to 'stack'. The stack driver writes to multiple channels (file, single, syslog, etc.), whereas the single driver writes exclusively to storage/logs/laravel.log. If your .env file contains a line like APP_LOG=stack but you haven't configured the stack drivers in config/logging.php, Laravel will attempt to write to non-existent channels or throw a silent failure depending on your error reporting settings.
To resolve this, verify the APP_ENV variable in your .env file. If you are running locally or in a development environment where exceptions trigger an HTML response page, ensure that the logging driver is explicitly set to 'single'. The configuration in config/app.php you provided uses env('APP_LOG', 'single'), which means it defaults to 'single' only if APP_LOG is missing. If your .env file has no APP_LOG key, this should work. However, if there is a hidden character or a typo in the .env file preventing Laravel from reading the default, the system might fall back to an unexpected behavior.
Check the contents of your storage/logs/laravel.log. If the file exists but remains empty, inspect the permissions on the storage/logs directory. While you mentioned that Storage operations work, confirming write permissions is still prudent, especially if the web server user (e.g., www-data) differs from the process owner. You can verify this with:
ls -la storage/logs
If the file does not exist and is not being created, ensure that the directory exists and is writable. Sometimes, if the log path is invalid or inaccessible for some reason, Laravel might silently skip writing to it in certain configurations, though this usually throws a warning which you should see on the exception page.
Another frequent pitfall involves the APP_LOG_LEVEL. You have set it to debug, but if your code is trying to write at INFO level or higher while the application runs in an environment that interprets the log driver differently, entries might be filtered out. However, since you are seeing exceptions on the screen, the logging system is active enough to catch errors for display; the issue is specifically with persistence.
Review your config/logging.php file. In Laravel 5.5, if you switch the driver from 'single' to 'stack', you must explicitly define the channels within that config file. If you accidentally left a custom configuration or switched drivers without updating the stack definition, Laravel might be logging to a channel that doesn't exist or is configured with an incorrect path.
Ensure your .env file does not contain any conflicting APP_LOG entries. Sometimes, multiple lines with the same key cause issues depending on how the environment loader processes them. A single, clean APP_LOG=single entry is often more reliable than relying solely on the default in config/app.php. If you are unsure, try removing APP_LOG from .env entirely to force the use of the 'single' driver defined as the fallback in your application config.
If you continue to experience issues after verifying permissions and configuration consistency, consider clearing the cache, as old configuration classes might be cached:
php artisan config:clear
php artisan cache:clear
Finally, if you are deploying this application and the logging stops working specifically in production while working locally, check if your deployment script is inadvertently setting APP_LOG to a value that requires a different driver configuration. Ensuring consistency between development and production .env files regarding the log driver type is essential for maintaining observability across environments.