0

I've spent way too long finding errors in some files because apache2 isn't logging errors in a way I thought it should.

I have my vhost configured to have its error log going to /var/www/mysite.com/log/error.log and when I was hitting the site, a zero byte file would be create but nothing appeared in the file.

After some digging, I found an error in a php file - my config.php in my apps folder. This file is included into a variable using php's require - e.g.

if (!$self::$config) {
    $file = '../app/config/config.php';
    self::$config = require $file;
}
return self::$config[$key]; //etc

but this obsfucates any possible errors that are inside config.php. So nothing can or ever will appear in the php error log. Is there a way to cause bugs inside required files to throw php errors? Is it a php or apache thing I can do?

  • what kind of errors are you expecting to find in the apache logs? What are the permissions and ownership of the log files you are looking at? I'd suggest starting there - basics first - before going on a long hunt for reasons data is not being written inside the log file you are looking at. Is this a shared hosting environment? – GoZippy Feb 27 '17 at 3:10
  • No, it's local dev, permissions are fine, it's a work environment so everything works as such. But I just expected that since errorlogging is set at crit it would have caught an error, or xdebug even; it seems like php's require hides the error inside the file. executing the required file standalone shows the problem immediately. but can I not catch errors in required files that are inserted into variables? – frumbert Feb 27 '17 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.