Fix check when to log