Where are logs located?

LaravelLoggingLaravel 5Laravel 5.2

Laravel Problem Overview


I'm debugging a JSON endpoint and need to view internal server errors. However, my app/storage/logs dir is empty and it seems there are no other directories dedicated to logs in the project. I've tried googling the subject to no avail.

How can I enable logging, if it's not already enabled and view the logs?

Laravel Solutions


Solution 1 - Laravel

  • Ensure debug mode is on - either add APP_DEBUG=true to .env file or set an environment variable

  • Log files are in storage/logs folder. laravel.log is the default filename. If there is a permission issue with the log folder, Laravel just halts. So if your endpoint generally works - permissions are not an issue.

  • In case your calls don't even reach Laravel or aren't caused by code issues - check web server's log files (check your Apache/nginx config files to see the paths).

  • If you use PHP-FPM, check its log files as well (you can see the path to log file in PHP-FPM pool config).

Solution 2 - Laravel

You should be checking the root directory and not the app directory.

Look in $ROOT/storage/laravel.log not app/storage/laravel.log, where root is the top directory of the project.

Solution 3 - Laravel

In Laravel 6, by default the logs are in:

storage/logs/laravel.log

Solution 4 - Laravel

The location of the log file can be found inside channels array config/logging.php (See below)

enter image description here

In case if some one is looking to write to the single channel, using Laravel's Log Facade, here's how to do.

Log::channel('single')->info('Your message');

Solution 5 - Laravel

Ensure that APP_DEBUG=true is set to on on you .env

If you want to easily check your storage log you can install:

https://github.com/rap2hpoutre/laravel-log-viewer

Solution 6 - Laravel

You can access the location programmatically by storage_path() . '/logs':

$logFiles = array_filter(
    scandir(storage_path() . '/logs'), 
    fn($fn) => !str_starts_with($fn,'.') // filter everything that begins with dot
);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlex LomiaView Question on Stackoverflow
Solution 1 - LaravelDenis MysenkoView Answer on Stackoverflow
Solution 2 - LaravelAliView Answer on Stackoverflow
Solution 3 - LaravelLuis Cabrera BenitoView Answer on Stackoverflow
Solution 4 - LaravelAnjana SilvaView Answer on Stackoverflow
Solution 5 - LaravelmpalenciaView Answer on Stackoverflow
Solution 6 - LaravelraverenView Answer on Stackoverflow