How do I log errors and warnings into a file?

前端 未结 7 1364
感动是毒
感动是毒 2020-11-22 04:43

How do I turn on all error and warnings and log them to a file, but to set up all of that within the script (not changing anything in php.ini)?

I want to define a fi

7条回答
  •  清酒与你
    2020-11-22 05:12

    Use the following code:

    ini_set("log_errors", 1);
    ini_set("error_log", "/tmp/php-error.log");
    error_log( "Hello, errors!" );
    

    Then watch the file:

    tail -f /tmp/php-error.log
    

    Or update php.ini as described in this blog entry from 2008.

提交回复
热议问题