You should log the time when you are either the pilot flying or the pilot monitoring whilst actually operating from one of the pilot seats when you are fulfilling that role. Supernumerary, jumpseat monitoring, or resting doesn't fulfill either the P1 or P2 roles and shouldn't normally be logged as such.