For follow-up discussion and general commentary on the topic. Comments are sorted chronologically.
A woman once came to me and confessed she was in an adulterous relationship. I told her she had to stop the affair and she immediately did. Then she asked me if she had to confess to her husband. I told her to do what was best for her marriage. She concluded that if she did confess to him their marriage would be over. I had known both of them for years and I think she was correct. He would not have been able to handle that information from her. She did not tell him and they stayed together. Assuming that if she had confessed to her husband it would have resulted in his divorcing her, do you people reading this response think she made the right decision?
It is a hard question and one that I have not committed in my 57 years of marriage, but I can see both sides. On the one hand if you confess it to your spouse they will always have doubts that you might do it again. It destroys the trust that we put in our spouse. Some can handle it better than others, and it is an excuse for divorce.
If there are children involved it even makes it more problematic. If the spouse can not handle the infidelity then there will be divorce. Now the children are left with out one of their parents.
But it may get back to your spouse through someone else, and then you have no choice but to confess it.
I would take it to the Lord in prayer and it may be the Lord will say to confess it and let the chips fall where they may.