- 정보공유
[PHP] 로그 기록 남기기 샘플
//----------------------------------------------------------------- // 로그기록 $log_txt = date('Y-m-d H:i:s', time()); $log_txt .= '|IP : '.getenv("REMOTE_ADDR"); foreach($_POST as $uk=>$uv) { $log_txt .= "|POST:".$uk."=".$uv; } foreach($_GET as $uk=>$uv) { $log_txt .= "|GET:".$uk."=".$uv; } $log_dir = $_SERVER['DOCUMENT_ROOT'].'/log'; // 쓰기권한 있는지 확인 필요 @mkdir($log_dir, 0755); @chmod($log_dir, 0755); $log_file = fopen($log_dir.'/pay_approval_'.date('Ymd', time()).'.log', 'a'); fwrite($log_file, $log_txt."\r\n"); fclose($log_file); //-----------------------------------------------------------------