Sayyiduna Jabir bin Abdullah (may Allah be pleased with them both) narrates that the Messenger of Allah (peace be upon him) forbade us from facing the Qiblah while urinating, then I saw the Messenger of Allah (peace be upon him) facing it (while urinating) one year before his death.
Related hadith on this topic