How do I recreate the accesslog?
There is no official way to do your own thing in statistics.php, it is on purpose kept as light as possible.

But of course, you can duplicate its functionality and do whatever you want. The whole trick is adding a JS file that sends an uncached POST request to the server. That's the only reliable way to get access statistics for anonymous users, as those requests might be cached by the page cache or an external CDN/Varnish.

Given that you already posted all the relevant code, I'm not sure what you are asking exactly. You even linked to the d.o issue that removed that feature, which links to the change record (https://www.drupal.org/node/1900384), which in turn links to the contrib module that provides similar functionality: https://www.drupal.org/project/better_statistics. So instead of doing it yourself, you could build upon that.