方法一
$date = date('Y-m-d'); $filePath = '/var/www/html/log'; if(!file_exists($filePath)) { mkdir($filePath, 0777, true); } $message = "\r\n" . 'Request Url: ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\r\n" . 'Request Param: ' . "\r\n" . file_get_contents('php://input') . "\r\n" . 'Request Time : ' . date('Y-m-d H:i:s') . "\r\n"; $message .= '------------------------------------------------------------------------------------------------' . "\r\n"; error_log($message, 3, $filePath . 'trace.log');
方法二
$file_path = 'logs/xx_'.date('Ymd').'.log'; $message = "\r\n" . 'Request Url: ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\r\n" . 'Request Param: ' . "\r\n" . file_get_contents('php://input') . "\r\n" . 'Request Time : ' . date('Y-m-d H:i:s') . "\r\n"; $message .= '--------------------------------------------------------------------------------------' . "\r\n"; file_put_contents($file_path, $message, FILE_APPEND);
429total visits,1visits today
Leave a Reply