3

In my Laravel 5.1 application, I've set APP_DEBUG to false for my production environment. However, I'd still like to see errors (exceptions) being logged to the log file.

In app/Exceptions/Handler.php I see the following method:

public function report(Exception $e)
{
    return parent::report($e);
}

where the parent::report method uses LoggerInterface to log errors. So I expect this already being taken care of for me. Nevertheless I don't see exceptions in my logfile.

How can I achieve this?

Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
EsTeGe
  • 2,975
  • 5
  • 28
  • 42
  • Are log files empty? Also don't forget to check files under storage/logs directory, in my app, log files are in the form laravel-2015-11-30.log. Maybe you checked the wrong file? (I did it once.) – berkayk Nov 30 '15 at 14:54
  • @berkayk Thanks, but I indeed checked the files under `storage/logs`. I use daily log files, but none exist in that folder. – EsTeGe Nov 30 '15 at 14:58
  • Have you checked write permissions as well? I know these are really basic questions but sometimes you miss these details. – berkayk Nov 30 '15 at 15:02
  • Did the check now, seems to be ok (`storage/logs` is writeable by `apache` user): `drwxr-xr-x. 2 apache apache 69 Nov 30 15:07 logs` – EsTeGe Nov 30 '15 at 15:06
  • Try triggering an log message manually - `Log::info('Test log message.'); `. If that doesn't work you'll know there's something wrong "further down". If you can, you can also try and enabling debug mode temporarily for the prod environment, say in the middle of the night - or some other time you web app/site has no users. – Arvid Nov 30 '15 at 16:49
  • 1
    Or, maybe you have som kind of configuration that makes the log writer not writing logs to disk? Check out the `'log'` setting in `config/app.php`, if it's set to `syslog` or `errorlog` it will not create log files in storage/logs – Arvid Nov 30 '15 at 17:02
  • For some reason, logging to file works again without touching anything. Might have been a server side issue. Thanks for the help everyone. – EsTeGe Dec 01 '15 at 08:06

0 Answers0