Yes, the IP address is logged as you can see for example if you have an Stack Exchange OpenID account on the https://openid.stackexchange.com/user page. The main sites will use similar techniques, but that isn't visible anywhere for us mere mortals.
The IP address information can be used to block accounts that actively spam the servers and in case of abuse of the system (voting fraud is among those). Active IP connections are stored at the firewall, to throttle you if you make to many requests. Those are probably shortlived, and I expect them to be only stored if there is a reason due to bugs or performance investigations.
When you use the network, we also collect potentially personally identifying information in the form of Internet Protocol (IP) addresses. But we don’t use that information to identify you, and we handle and disclose these addresses in the same way we handle other potentially personally identifying information as described below.
This is all governed as part of Personally Identifying Information.