Skip to content

Laravel Logs

By Jasper Frumau

Laravel Logs are normally decided in config/app.php and your .env file.  Let’s go through all the configuration options here and how you can set up logging locally properly as well as on production.

App Configuration

Inside config/app.php – the center of your application – you will find several details on how logging is done. Here you indicate whether you are at production, staging or development level. And here you also indicate what type of logging you will do and whether or not debugging is turned on in the first place.

Error Logging

In your config/app.php you will normally find the following line:

'log' => env('APP_LOG', 'single'),

there by default. This normally means the logs should be located at:

domain.com/storage/logs/laravel.log

It also means it will be stored in a single file. The file still has to be created there though. Also make sure it is writable:

vagrant@homestead:~/app/path/to/storage/logs$ stat -c "%a %n" *
755 laravel.log

Types of Error Logging

There are other options besides single file logging which can grow a lot over time. You have:

  • single
  • daily
  • syslog
  • errorlog

as other options at your disposal. Options like maximum daily storage of errors.

Activating Debugging

To see whether debugging is turned on go and find a line with debug in app.php. By default it is turned off here:

'debug' => env('APP_DEBUG', false),
And for production it is better to have it turned off of course. You can adjust this in app.php or simply in your .env file. Adjusting in your .env file is in fact the best place.

Debug Setup with .env

For local development we have a different setup than staging or production and for each environment we have our own .env file. Inside your .env you normally have:

APP_DEBUG=true
APP_LOG_LEVEL=debug
when your in your development environment. This shows debugging has been turned on and your debug log level is at debug. Make sure this .env file is loaded, otherwise nothing will be recorded. In production this is normally set to false to not expose errors to your clients or hackers.