You have the right to log IP addresses only if they are used for the two purposes you listed, otherwise you will need explicit consent.