Solution (source code)

= Solution

By cylindrical symmetry the <electric field> of an infinite <line charge> is radial, independent of $z$ and angle. Use a coaxial cylindrical <Gaussian surface> of radius $r$ and length $L$. The end caps have zero flux, so <Gauss's law> gives $2\pi rL E_r=\mu L/\varepsilon_0$. Hence \b[the field and electrostatic potential are]
$$
\boxed{\mathbf E=\frac{\mu}{2\pi\varepsilon_0r}\mathbf e_r,\qquad \phi(r)=-\frac{\mu}{2\pi\varepsilon_0}\log\frac r{r_0}+C.}
$$
Here $r_0>0$ is an arbitrary reference length, and $\mathbf E=-\nabla\phi$. One cannot choose zero <electrostatic potential> at infinity for a single infinite <line charge>, because its logarithmic potential diverges there; the arbitrary reference handles the additive constant.