Sahih Bukhari | Volume 1 | Hadith Number 388

Narrated by Abu Aiyub Al-Ansari
The Prophet said, "While defecating, neither face nor turn your back to the Qibla but face either east or west." Abu Aiyub added. "When we arrived in Sham we came across some lavatories facing the Qibla; therefore we turned ourselves while using them and asked for Allah's forgiveness."