Abdullah bin Umar (may Allah be pleased with them both) said that people used to say: "When you sit to relieve yourself, do not face the qiblah or Bayt al-Maqdis." Abdullah bin Umar (may Allah be pleased with them both) said: I climbed onto the roof of our house and saw the Messenger of Allah (peace and blessings be upon him) on two bricks, and he (peace and blessings be upon him) was facing Bayt al-Maqdis while relieving himself.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 435