I do it more or less like this in my projects (here the basics, of course more advanced depending on project, error checking and so on)
javascript
function doLog(somedata) {
$.ajax({
url: "ajax_log.php",
//data, an url-like string for easy access serverside
data : somedata,
cache: false,
async: true,
type: 'post',
timeout : 5000
});
}
serverside
most of the times I use a class that inserts each element from somedata as rows in some log-tables, like a table log with id and timestamp, and a table logParams, with id and param / value. But that is for statistically porpuses. Other times it is only nessecary to log somedata in a file
<?
$file="log.txt";
$text=serialize($_POST);
$fh = fopen($file, 'a') or die();
fwrite($fh, $text."\n");
fclose($fh);
}
?>
So it is very easy to make a log-system executed by JS, and not hard to implement almost anything in it