Search code examples
phpapacheerror-log

Php error log not working correctly


i have error in my page but it is not logs in to the log file
i have set

display_errors:Off
display_startup_errors:Off
error_log:error_log
log_errors:On

i have restarted apache after configuration but it is not working

just checked the apache file /etc/httpd/logs/error_log file it contain the error but why the error_log does not creating in the folder in which error occurs


Solution

  • try this in your php file

    ini_set("log_errors", 1);
    ini_set("error_log",$_SERVER['DOCUMENT_ROOT']."/logs/php-error.log");
    

    Give write permission to the folder logs and its file, then check the file in logs folder.

    error_log:error_log
    

    error_log not has correct path, set a correct path like below

    log_errors = On
    error_log =  "C:\xampp\php\logs\php_error_log"