Logic is the art of correctly deducing one idea from another and inferring from a fact all its consequences. But logic does not itself possess the capacity to discern the truth. So your logic may be indisputable, but if your starting-point is wrong, your conclusions will also be wrong, in spite of the correctness of your logic, or rather, because of it. The same holds true for self-righteousness, which is a feeling of virtuous superiority.
Your virtue makes you disdainful of others, and this pride – which fills you with disdain for those who, according to you, are less virtuous than you are – makes your virtue completely worthless.
That is why Sri Aurobindo tells us in his aphorism that logic is the worst enemy of Truth, just as the feeling of virtuous superiority is the worst enemy of virtue.
Ref: On Thoughts and Aphorisms