Magnetic vector potential of an infinite wire Using the integral $$A=\frac{\mu_0}{4 \pi} \int \frac{I \vec{dl}}{r}$$ for calculating magnetic vector potential of an infinite wire we get $$A = \left(\frac{\mu_0 I}{4 \pi}\right) \ln(\sec \theta + \tan \theta)$$ which diverges when the limits are from $-\pi$ to $\pi$. We can get around this by solving $B=\nabla \times A$ which gives us a finite answer.
My question is why does the first formula fail for this problem and is it fixable?
 A: Ok, so lets start with the basics, the answer we are expecting is given by:
$$\vec B= \frac{\mu_0I}{2\pi r} \hat e_\theta$$
Which is from Ampere's law. 
From this we can kind of backwards engineer, to show that:
$$\vec A=-\frac{\mu_0I}{2\pi} \ln(r) \hat e_z$$
would work as the potential.
The reason I don't think your method works is because you are forcing the coulomb gauge (i.e. $\nabla \cdot \vec A=0$) onto the system and in this situation the integral diverges.  In other words we have the freedom to chose $\vec A$ since:
$$\vec A'=\vec A+\nabla(\phi)$$
For some function $\phi$ both satisfy: 
$$\vec B=\nabla \times \vec A=\nabla \times \vec A'$$
It happens that your choice of $\vec A$ is not well defined in this case, i.e. the coulomb gauge doesn't work.
A: Below picture shows an infinite wire and an imaginary loop for calculating the vector potential super much easier.

$$
\begin{align}
B &= \nabla \times A \\
\iint B \cdot \mathrm{d}a &= \oint A \cdot \mathrm{d}l \\
\int_a^b \frac{\mu l}{2 \pi r} L \, \mathrm{d}r &= AL \\
A &= \frac{\mu l}{2 \pi} \ln{\frac{b}{a}} Z
\end{align}
$$
A: The reason that the formula fails is because you have computed the integral wrong. The coulomb gauge does work, it by definition MUST.
The equation for A is
$\nabla(\nabla \cdot \vec{A}) - \nabla^2 \vec{A} = -\mu_0 \vec{J}$
In the coulomb gauge $\nabla \cdot \vec{A} $= 0
This means the equation for A reduces to
$\nabla^2 \vec{A} = \mu_{0} \vec{J}$
Now...
The standard solution to A in the context of line currents is
$A(\vec{r})=\iiint \frac{\mu_{0}I}{4\pi} \frac{\vec{dl}}{|r-r'|}$
Notice that this is basically the same equation for the scalar potential V in the context of electrostatics. Notice also that when computing the electrostatic potential where infinity is NOT our reference frame, there is a +c on this integral. And when infinity is taken to be our reference point, the plus C vanishes. In the context of electrostatics, the gradient of a constant is zero so it doesnt change the physics, much like in magnetostatics the curl of a constant is zero. Meaning the B field is the same. What does this mean? Well this means that in the coulomb gauge I can have a non divergence potential. This doesn't matter, as I will prove to you now that even the divergent one can still yield a correct result.
For a wire in the z plain, of infinite length. Current I, using cylindrical coordinates
Where I am evaluating my point at $<\rho,\theta,0>$
And the wire is located on the z axis, using the variable z' to specify the location of my wire. The integral I would have to solve is:
$A(\vec{r})=\iiint_{-\infty}^{\infty} \frac{\mu_{0}I}{4\pi} \frac{ \hat k dz'}{\sqrt{(\rho)^2+(z')^2}}$
Note that Since the wire is infinite, I will be choosing the location I am evaluating the B field to  be z=0 ( I don't have to , but later I will use symettry to say that it is 2x the integral from 0 to infinity, and to be honest, I'm not sure if I can say this when z isn't in the center, I suspect I can ,since the wire is infinity, but for now I'll stick with z=0)
To solve this i will need to make the substitution
$z'= \rho tan(\phi)$
$dz'=\rho sec^2(\phi) d\phi$
$A(\vec{r})=\iiint_{-\infty}^{\infty} \frac{\mu_{0}I}{4\pi} \frac{\hat k \rho sec^2(\phi) d\phi  }{\sqrt{(\rho)^2+(\rho tan(\phi))^2}}$
$A(\vec{r})=\iiint_{-\infty}^{\infty} \frac{\mu_0 I}{4\pi} \frac{ \hat k \rho sec^2(\phi) d\phi  }{\sqrt{(\rho)^2+\rho^2 tan^2(\phi)}}$
$A(\vec{r})=\iiint_{-\infty}^{\infty} \frac{\mu_0 I}{4\pi} \frac{\hat k \rho sec^2(\phi) d\phi  }{\sqrt{(\rho)^2(1+tan^2(\phi))}}$
$A(\vec{r})=\iiint_{-\infty}^{\infty} \frac{\mu_0 I}{4\pi} \frac{\hat k \rho sec^2(\phi) d\phi  }{(\rho)(sec(\phi))}$
$A(\vec{r})=\iiint_{-\infty}^{\infty} \frac{\mu_0 I}{4\pi}  \hat k  sec(\phi) d\phi  $
which is a nice and simple integration
=$ \frac{\mu_0 I}{4\pi}    ln|sec(\phi) + tan(\phi)|\hat k$
Evaluated from -$\infty$ to $\infty$
Due to symmetry this is the same as 2x the integral from 0 to $\infty$
$\frac{\mu_0 I}{2\pi}    ln|sec(\phi) + tan(\phi)|\hat k$
Evaluated from 0 to $\infty$
now here is where you have gone slightly wrong, we need to change the bounds to be in a form that is $\phi$
$z' = \rho tan(\phi)$
When z' =0, it is clear that $tan(\phi)$ is zero,
Drawing a triangle, with angle $\phi$ we can also see that $ln|sec(\phi)|$ is also zero.  Meaning the contribution is zero. (
Now let's look at the more "tricky bound"
naively plugging in infinity, and then saying that tan(phi) is infinity, doing the same for sec, would also naively get you infinity
THIS IS WRONG firstly, we can clearly see that,as plugging in infinity to $\rho$ wouldn't make A infinity... the inside of the log actually comes out to be $\sqrt(2) + 1$
To evaluate this easily
draw a triangle,
$Tan(\phi)= \frac{z'}{\rho}$
$Sec(\phi)= \frac{\sqrt{(\rho)^2+(z')^2}}{\rho}$
Thus our integral evaluates to
$\frac{\mu_0 I}{2\pi}   ln| \frac{\sqrt{(\rho)^2+(z')^2}}{\rho} + \frac{z'}{\rho}| \hat k $
Simplifying,
$\frac{\mu_0 I }{2\pi}   ln| \sqrt{1+(\frac{z'}{\rho})^2} + \frac{z'}{\rho}| \hat k $
Here we have it in a form with our "missing" variables! The integral is divergent, that is no problem! We can STILL obtain our fields.
Computing the curl in cylindrical coordinates is easy, since it only has a z component, so the curl is
$B = \frac{dA}{d\rho} \hat \theta$
Now take the limit as z' goes to infinity!
doing so, gets you ALOT AND ALOT of messy algebra and limits! But if you go through it carefully, you DO  get the correct magnetic field that
$\vec{B(\rho)} = \frac{\mu_0 I}{2\pi\rho} \hat \theta$
Yes it is a pain in the a** but even this divergent integral gives you the correct B field with careful mathematical treatment! The coulomb gauge STILL works( It is a "fun" exercise to do, give it a try)
