开发者

PHP log: Warning format

开发者 https://www.devze.com 2023-03-11 17:04 出处:网络
The PHP log format does not include the date, for Warnings. For instance PHP Warning:Cannot modify header information...

The PHP log format does not include the date, for Warnings. For instance

PHP Warning:  Cannot modify header information...

does not have any date of when the warning happened.

Is there a way to change the Warning format, or at leas开发者_开发技巧t have the date in the log? (usingphp-fpm if it matters).


You can of course always define your own error handler using set_error_handler. Simplified example:

function handler($errno, $errstr, $errfile, $errline, $errcontext) {
    $message = date('Y-m-d H:i:s') . ": $errstr in $errfile at $errline\n";
    file_put_contents('error.log', $message, FILE_APPEND);
}

set_error_handler('handler');
0

精彩评论

暂无评论...
验证码 换一张
取 消