I interviewed at both for prelim and am from the SF Bay Area.
Both will give you excellent training and prepare you for fellowships. Both have happy residents. You kind of have to choose your team since both select for different folks in my experience.
The livin' is a bit easier at Stanford and the residents I talked to liked that they had fewer social issues to deal with and the facilities are very nice (night and day compared to UCSF when comparing all three sites; VA vs VA--wow, SFGH vs. SCV, Moffitt vs. Stanford). Their PD was awesome and very approachable and 2-3 residents noted that they chose Stanford over UCSF because they had a more informal, friendly connection to the attendings.
UCSF folks (residents and faculty alike) tend to embrace the urban/county experience more and have more of an activist bent. This is especially true of the SFGH primary care residents who are amazingly accomplished and are pretty involved in social justice causes. UCSF residents came off as more passionate to me, since they did acknowledge the crappy facilities and having to do a lot on their own. I admire that they seemed to be so into their program and their patients that they were really happy despite those inconveniences.
Of course, I'd choose living in SF over Palo Alto anyday. The cost of living is about the same. For people with kids, I hear the wait list for good Palo Alto schools starts when the kid is delivered. No firsthand experience.
You probably can't go wrong when choosing betweeen the two. Good luck!