All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
It is neither permissible to spy on the Muslims nor to reveal their faults because Allah says (what means): {And do not spy.} [Quran 49:12]
If a person commits a sin in secret, it is not permissible to reveal his secret, or to spy on him. In case his sin is known, and he is not a person who is known to commit sins, then it is more appropriate to conceal his sin and advise him to sincerely repent to Allah.
However, if the person commits sins openly and he does not care about that, then it is more appropriate to take his matter to the ruler so that the Hadd (the corporal punishment determined by Islamic Law) will be implemented on him in order to deter him and frighten others from doing such a sin.
The Fiqh Encyclopedia reads:
“It is Islamically determined: that it is obligatory to conceal the sins of a Muslim if he is not known to harm the people, or do corruption. The Prophet said: 'Whoever conceals the sins of a Muslim, Allah will conceal his sins on the Day of Judgment.' Sharh Muslim reads: 'This concealing is in regard to those who are not known to commit sins. Ibn al-Arabi said: If you see a person committing a sin, then advise him secretly and do not expose him.'" [End of quote]
Shaykh Ibn 'Uthaymeen said:
"Concealing the sin of a person may be an ordainment and praiseworthy, and it may be forbidden. If we see a person committing a sin, and he is a wicked man who is indulging in sin, and concealing his sin will only increase his evil and wrongdoing, then we do not conceal him; rather, we report him so that he will be deterred; a deterrence that will achieve the objective." [End of quote]
As regards the person who commits a sin and his matter is not disclosed, then it is better for him to conceal himself, and his repentance will be accepted between himself and his Lord if he fulfills its conditions, no matter how great his sin is, provided that he returns the rights to their owners if he has transgressed the right of anyone.
Allah knows best.