Gabotronix's avatar

Question about laravel and nginx logs

Hi everybody, I have a noob question. On my lemp stacl I always define access and error log files for nginx in /var/log/appname folder and then in my nginx conf I have:

access_log /var/log/clunkertree.com/access.log;
    error_log /var/log/clunkertree.com/error.log;

I also know that laravel has laravel.log file in storage, in this file all errors such as 404, 500, Exceptions are logged, now I just checked my access.log file and it has many lines, all right but ALL my error logs are empty, this has led me to believe that I shouldn't really be creating a error.log file since it appears all laravel errors are logged into laravel.log file, onlu an access.log and laravel's default laravel.log file will suffice, am I mistaken??

0 likes
3 replies
bobbybouwmann's avatar

Well there are multiple kind of errors here.

Applications errors: Things like exceptions and basic php errors can be found in laravel.log files.

PHP failures: Sometimes a class cannot be found, these kind of errors cannot be caught by Laravel, because the framework isn't running yet. Then fpm will catch this error and log it somewhere (these are the fpm errors log files)

The nginx error.log file is not being used in most cases. Only if you set the error log driver in laravel to syslog, which is not the default in Laravel. So if you want your errors in there, you need to switch the driver in Laravel.

I doesn't hurt to add this file, just to be sure ;)

Cronix's avatar

It's good that the error log is empty. That's what you're going for ---- NO ERRORS.

Access log is completely different. It shows everything that was accessed, both successfully and unsuccessfully, with and without errors. For instance, when loading your homepage, you are accessing many things. You access the html file, you access the css files, you access the js files, you access every single image on the page. Each of those accesses get logged.

The error log typically shows php errors and has nothing to do with whether an image was successfully retrieved or not, so those won't be in that log file. Only errors.

Gabotronix's avatar

Okk that made things more clear, thanks guys!

Please or to participate in this conversation.