Since integrand is even function, so
$\int_{0}^{\infty} \frac{\ln\left(a^2+x^2\right)}{b^2+x^2}dx$=$\frac{1}{2}\int_{-\infty}^{\infty} \frac{\ln\left(a^2+x^2\right)}{b^2+x^2}dx$
so solving the R.H.S using residues--
$\int_{C} f(z)dz=\int_{Cr} f(z)dz +\int_{-R}^{R}\frac{1}{2} \frac{\ln\left(a^2+x^2\right)}{b^2+x^2}dx$
where C is closed loop in upper half of plane and f(z)= $ \frac{1}{2}\frac{\ln\left(a^2+z^2\right)}{b^2+z^2}$
and f(z) becomes $\frac{1}{2}\frac{\ln\left(a^2+z^2\right)}{(z+bi)(z-bi)}$ by factorizing denominator
there for f(z) has singularities at z=+bi,-bi, but only z=bi lie in upper half of plane
so,$\int_{C} f(z)dz=2(pi)(i)$[residue of f(z) at $bi$]
and as R goes to infinity $\int_{Cr} f(z)dz-->0$
we get
$\int_{0}^{\infty} \frac{\ln\left(a^2+x^2\right)}{b^2+x^2}dx=\int_{C} f(z)dz=2(\pi)(i)$[residue of f(z) at $bi$]
=$\frac{\pi}{2b}\ln(a^2-b^2)$