Request-Uri: /custom/foobar
Request-Params: {"action":"edit"}
actually, this should already be in access.log(the last 500 error
one)...... I don't see why you need it in error log....
Sorry, my example is not precise enough. Normally, $_POST, $_SESSION['username'] and php://input are not part of access.log. So having ajax requests with all kinds of inputs makes things more difficult.
Parsing complete access logs can be quite slow and logging php://input for every request might not be possible in most cases.
Regards
Thomas
Xinchen Hui wrote on 28.01.2015 07:15:
There are some workarounds with register_shutdown_function to extend
E_ERROR
messages, but I think that's quite dirty in a system with many parallel
requests.
Here is an example:<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', 'php_error.log');
ini_set('date.timezone', 'Europe/Berlin');
ini_set('memory_limit', '16M');$_SERVER['HTTP_HOST'] = 'mywebsite.com';
$_SERVER['REQUEST_URI'] = '/custom/foobar';
$_REQUEST = array('action' => 'edit');function check_for_fatal() {
$error =error_get_last()
;
if ($error['type'] == E_ERROR) {
$errstr = '';
if (!empty($_SERVER['REQUEST_URI'])) {
$errstr .= ' Request-Uri: '.$_SERVER['REQUEST_URI'].PHP_EOL;
}
$errstr .= ' Request-Params: '.json_encode($_REQUEST);
file_put_contents('php_error.log', $errstr. PHP_EOL, FILE_APPEND);
}
}register_shutdown_function('check_for_fatal');
$str = str_repeat('##########', 210241024);
gives:
[28-Jan-2015 07:00:53 Europe/Berlin] PHP Fatal error: Allowed memory size of
16777216 bytes exhausted (tried to allocate 20971521 bytes) in test.php on
line 27
Request-Uri: /custom/foobar
Request-Params: {"action":"edit"}
actually, this should already be in access.log(the last 500 error
one)...... I don't see why you need it in error log....thanks
Regards
ThomasXinchen Hui wrote on 27.01.2015 13:26:
Hey:
Hi Thomas,
Here is the rfc:
https://wiki.php.net/rfc/error_handler_callback_parameters_passed_by_reference
Thanks to reeze for coding and putting it on the wiki.
It looks good to me.
Future Scope
set_error_handler()
callback might be able to handleE_ERROR
to be able to
append additional information to memory_limit exhaustions (or others).I really want to catch E_RROR by user defined error handler. The only
reason why this was disabled is abuse of error handler. We may document
abuse of error handler withE_ERROR
may result in undefined behavior
including memory leak/crash and allow it.
I feel it's kindof wrong direction.if you want custom logs, maybe you should use custom logger.
thanks
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net--
Xinchen Hui
@Laruence
http://www.laruence.com/