I know that the solution is $\frac{arctan(\frac{x}{a})}{a}$, however the thought popped into my head of trying to show this by using partial fractions and logs.
I rewrote $\frac{1}{x^2+a^2}$ as $\frac{1}{2ai}(\frac{1}{x-ai}-\frac{1}{x+ai})$. Then my chain of thought went as follows:
$\frac{1}{2ai} \int\frac{1}{x-ai}-\frac{1}{x+ai} dx$
$=\frac{1}{2ai}(log(x-ai)-log(x+ai))$
$=\frac{1}{2ai}(log(|x-ai|*e^{arg(x-ai)i})-log(|x+ai|*e^{arg(x+ai)i}))$ (rewriting the complex numbers in modulus-argument form)
$=\frac{1}{2ai}(log(e^{arg(x-ai)i})-log(e^{arg(x+ai)i}))$ (using the addition rule of logs and cancelling the resultant $log(|x-ai|)$ and $log(|x+ai|)$)
$=\frac{1}{2ai}(arg(x-ai)i-arg(x+ai)i)$
$=\frac{1}{2a}(arg(x-ai)-arg(x+ai))$
$=\frac{1}{2a}(arctan(\frac{-a}{x})-arctan(\frac{a}{x}))$
$=\frac{1}{2a}(-2arctan(\frac{a}{x}))$ (using $arctan(-x)=-arctan(x)$)
$=\frac{-1}{a}arctan(\frac{a}{x})$
Which is close to, but clearly not, the actual answer. I cannot see where I went wrong with my thinking. Can anyone tell me where my error is?