I’m running some scripts via AJAX, and I’d like to log errors to a log file.

In php.ini I have the error_log pointing to /var/log/php_errors.log

And I’m attempting to log errors in my script like so:

error_log("Some variable: " . $var);

There’s no log file being generated in /var/log though.

Am I missing something?

Thanks in advance,

Have you look at your root folder?
If log file is not generated as file, then probably it is in the CPanel under error log.

I’m annoyed, just lost a big reply I had staged for you. Heres the shorter version:

  1. error_log returns a boolean value of its success or failure
  2. check phpinfo(); for path
  3. path must be defined in apache or php

My suggestion and how I handle errors:
Use autoprepend ini settiing to auto run a php file with a custom class that:

  1. sets set_error_handler to customer function
  2. use that function to throw a new exception with message of the error
  3. set_exception_handler to customer function (will catch all exceptions including newly created ones from errors)
  4. use that function to do you logging and in my case, an email to IT with var dumps of the entire request.

This approach will show you errors that you didn’t even know were occurring. Amazingly handy for production deployments