PHP - error_log () will not print to file

The name pretty much says it all. I tore my hair, trying to make it work all day. I am in the process of creating a PHP-based login system and I need to do some debugging. The most useful thing for me now is the ability to write debugging messages to a file at specific points throughout the PHP program. Based on the documentation, it looks like this is what I should do error_log(), but despite everything I tried, I had absolutely no success. A complete list of everything I've tried below:

  • Added /etc/php/7.0/apache2/php.ini

    following:
    error_reporting = E_ALL
    display_errors = On
    log_errors = On
    
  • Also, try setting error_logto locations within /usr/, /var/www/http/and/home/

  • Use ini_set()and error_reporting()to set all of these variables, including error_logfrom the PHP file

  • Manually create the files to be written to, and set their owner and group to www-dataand their permissions at 777

  • And last but not least, reinstallation libapache2-mod-php7.0and php7.0, to no avail

  • Basically everything except using my laptop to break the 3-story window of my office building just before proceeding with my alleged death

I really can’t find anything else to try on Google, so I decided that I would ask the experts, and I was here. If anyone can provide any suggestions, we will be very grateful.

+4
source share
1 answer

, sys, error_log() .

error_log("An error occured", 3, "/var/tmp/my-errors.log");

, php fpm, www-data, , chmod

3 , -

apache, httpd.conf (v, ErrorLog

ErrorLog "/var/log/apache2"

, ls -la ll ..

 -rwxrwxr-x 1 www-data www-data 

- .

- php.ini(CLI apache php.ini)

 error_log = /var/log/phperrors.log 

 touch /var/log/phperrors.log
 chown www-data: /var/log/phperrors.log
 chmod +rw /var/log/phperrors.log

, , set_error_handler(), , php. , . , , , , php.ini ini_set() , .

+1

Source: https://habr.com/ru/post/1694554/


All Articles