Yes, and no.
It helps because you will see proofs, you will see careful statements and you will learn, even if not directly more examples that can be used later on to study mathematical logic better.
But on the other hand, rarely anyone mentions formal logic in a course about analysis. You don't think about the inference rules, or what sort of statement you're writing, and so on. This might come up in set theory, or in model theory courses, but even then, you might be surprised how little thought we give these processes.
I am teaching a course about naive set theory (well, I'm the TA, but I'm giving a minicourse about extended topics under the guise of an exercise session). In the first class I wrote that if a set is not empty we can pick an arbitrary element of that set.
I've used existential instantiation, to move from $\exists x(x\in X)$ to an actual element $x$ from $X$; of course I didn't mention this. I hoped that they will let it slide, and they did.
But sure enough, when we discussed the axiom of choice, some six weeks later, they asked why can we choose from one non-empty set? How can we be sure that this is doable? And I explained that we have been doing that since the first class. The reason is the rules of logic, which we didn't mention to them -- because it's a naive set theory course, and these rules are applied naively.
To sum up, yes, taking math courses can help (at least those that deal with proofs) and it is very important to learn some basics as well, algebraic structures make excellent examples for theories and models in logic; but don't expect any mention of logic in those courses. You still have to learn it properly on its own.