What sort of data should be logged on a social networking type of site from day 1 so that in the future, useful statistical analysis may be performed? Also, what other tips and tricks have you learned with site logging? Depending on the scale of the site, is it frequently worth it to log to a flat file, and have a job periodically load that data into a db for site-performance reasons?

I am thinking of server side logging here - not just generic google analytics / piwik type logging. To give a jumpstart to the answer, here are a few no-brainers I've thought of:

* ip address
* user identification info, if logged in (userid)
* HTTP\_REFERRER
* is ajax call (bool)
* session id (should sessions also be permanently logged separately?)
* Nth # of views since session began
* some sort of information to indicate what page user is on (controller being used? Url path?)
* timestamp