Fourier transform of $ \log(x^{2}+a^{2}) $ I would like to evaluate the Fourier cosine transform of $\log(x^{2}+a^{2})$
or the integral
$$\int_{0}^{\infty}\cos(ux)\log(x^{2}+a^{2})\,dx$$
for any real $u,a$.
However, it seems that this integral may be divergent due to the behaviour of the logarithm so what should I do?
 A: Let us assume $a>0$ without loss of generality.
It is possible to evaluate this Fourier transform in the sense of distributions as follows. I am going to assume that, due to the parity of the integrand, the one-sided transform from $0$ to $+\infty$ is equal to $1/2$ the Fourier transform from $-\infty$ to $+\infty$,
$$
\int_0^\infty \cos(ux)\log(x^2+a^2)dx=\frac{1}{2}\mathcal F\big[\log(x^2+a^2)\big]\equiv T(u)\,,
$$
where
$$
\mathcal F[\,f\,] \equiv \int_{-\infty}^{+\infty} f(x)\,e^{-iux}dx\,.
$$
Multiplying by $iu$ and using the properties of the Fourier transform
$$
iu T(u)=\frac{1}{2} \mathcal F\big[\partial_x \log(x^2+a^2)\big] =i \partial_u \mathcal F\big[(x^2+a^2)^{-1}\big]\,.
$$
Now, we can use the well known integral
$$
\mathcal F\big[(x^2+a^2)^{-1}\big]=\int_{-\infty}^{+\infty}\frac{e^{-iux}}{x^2+a^2}dx=\frac{\pi}{a}e^{-a|u|}\,,
$$
which can be obtained by contour integration. Substituting above,
$$
uT(u)=\frac{\pi}{a}\partial_u e^{-a|u|}\implies uT(u)=-\pi\, \mathrm{sgn}(u)e^{-a|u|}\,.
$$
The general solution to this equation is
$$\boxed{
T(u)=-\frac{\pi}{|u|}e^{-a|u|}+C\delta(u)\,
}$$
where $|u|^{-1}$ is understood in the sense that, for any test function $\varphi$,
$$
\langle |u|^{-1}, \varphi(u) \rangle =  \int_{|u|>1} \frac{\varphi(u)}{|u|} du + \int_{|u|<1} \frac{\varphi(u)-\varphi(0)}{|u|}du\,,
$$
while $C$ is, for now, an arbitrary real constant. In order to fix $C$, we can calculate the inverse Fourier transform:
$$
\frac{1}{2}\log(x^2+a^2)=(\mathcal F^{-1} T)(x)\,.
$$
Contracting with an arbitrary test function $\varphi$ and denoting the Fourier transform by $\tilde{}$,
$$
\langle \log(x^2+a^2),\varphi(x)\rangle = \langle T(u), \frac{1}{\pi}\tilde \varphi(-u)\rangle\,.
$$
Using the definition of $|u|^{-1}$,
the right-hand side can be recast as
$$
\langle 2\Re\int_0^\infty \frac{du}{u}(\theta(1-u)-e^{-(a-ix)u})+\frac{C}{\pi}, \varphi(x)\rangle\,.
$$
We introduce a regulator to calculate the integrals explicitly:
$$
\int_0^1 \frac{du}{u^{1-\epsilon}}=\frac{1}{\epsilon}
$$
$$
\int_0^\infty \frac{du}{u^{1-\epsilon}}e^{-(a-ix)u}=\frac{\Gamma(\epsilon)}{(a-ix)^\epsilon}=\frac{1}{\epsilon}-\gamma_E-\log(a-ix)+\ldots
$$
Thus,
$$
\log(x^2+a^2)=2\gamma_E+\log(a^2+x^2)+\frac{C}{\pi}\implies C=-2\pi \gamma_E\,.
$$
The final answer is thus
$$\boxed{
\int_0^\infty \cos(ux)\log(x^2+a^2)dx=-\frac{\pi}{|u|}e^{-a|u|}-2\pi \gamma_E\delta(u)\,}.
$$
In this way we have obtained the same result as this answer (or this answer). As emphasized there by Maxim, and also by Mark Viola in the comments, the assumption of trading the original integral with the two-sided transform is not as innocuous as it may look. Upon making that assumption, we indeed recover the same result, while a more rigorous and general approach is presented here by Mark Viola.
A: For an even function, the two-sided cosine transform coincides with the complex exponential transform, so the answer will be the same as here:
$$\int_{-\infty}^\infty \ln\left( x^2+a^2 \right) \cos u x \,dx =
-2 \pi \left( e^{-\left| a u \right|} \left| u \right|^{-1} +
 2 \gamma \delta(u) \right),$$
which can be verified by computing the inverse transform.
For a one-sided transform, first you would have to extend the definition of the transform itself to make it applicable to distributions, because the integral from zero to infinity of the delta function is undefined.
A: I thought that it might be instructive to present an approach to deriving the Fourier transform of $\log(x^2+a^2)$ that uses a regularization approach that is distinct from and complements the methodology I developed in THIS ANSWER.  To that end, we now proceed.


PRELIMARIES
Let $\psi(x)=\log(x^2+a^2)$ and let $\Psi$ denote its Fourier Transform.
Then, we write
$$\Psi(k)=\mathscr{F}\{\psi\}(k)\tag 1$$
where $(1)$ is interpreted as a Tempered Distribution.  That is, for any $\phi \in \mathbb{S}$, where $\mathbb{S}$ is the Schwartz Space, we can write
$$\langle \mathscr{F}\{\psi\}, \phi\rangle =\langle \psi, \mathscr{F}\{\phi\}\rangle$$
Now, let $\psi_\epsilon(x) =e^{-\varepsilon|x|}\log(x^2+a^2)$, $\varepsilon>0$.  Therefore, $\psi(x)=\lim_{\varepsilon\to 0^+}\psi_\varepsilon(x)$ and we see that
$$\begin{align}
\lim_{\varepsilon\to 0^+}\langle \mathscr{F}\{\psi_\varepsilon\}, \phi\rangle&=\lim_{\varepsilon\to 0^+}\langle \psi_\varepsilon, \mathscr{F}\{\phi\}\rangle \\\\
&=\langle \psi,\mathscr{F}\{\phi\}\rangle\\\\
&=\langle \mathscr{F}\{\psi\}, \phi\rangle\tag2
\end{align}$$
Next, we will evaluate the Fourier transform of $\psi_\varepsilon$ and subsequently use $(2)$ to find the Fourier Transform of $\psi(x)$.


EVALUATING THE FOURIER TRANSFORM OF $\displaystyle \psi_\varepsilon$
Denote by $\Psi_\epsilon$, the Fourier transform of $\psi_\varepsilon$.  Then, we have
$$\begin{align}
\Psi_\varepsilon(k)&=\mathscr{F}\{\psi_\epsilon\}(k)\\\\
&=\int_{-\infty}^\infty e^{-\varepsilon|x|}\log(x^2+a^2) e^{ikx}\,dx\\\\
&=2\text{Re}\left(\int_0^\infty e^{-(\varepsilon -ik)x}\log(x^2+a^2) \,dx\right)\tag3\\\\
&=\frac{4\varepsilon \log(|a|)}{k^2+\varepsilon^2}+2|a|\int_0^\infty e^{-\varepsilon |a| x}\cos(|a|kx)\log(x^2+1)\,dx\\\\
&=\frac{4\varepsilon \log(|a|)}{k^2+\varepsilon^2}-4\int_0^\infty \frac{e^{-\varepsilon |a|x}(|k|x\sin(|ak|x)-\varepsilon x\cos(|ak|x))}{(x^2+1)(k^2+\varepsilon^2)}\,dx\tag4\\\\
&=\psi^{(1)}_\varepsilon+\psi^{(2)}_\varepsilon+\psi^{(3)}_\varepsilon
\end{align}$$
where in $(4)$
$$\begin{align}
\psi^{(1)}_\varepsilon(k)&=\frac{4\varepsilon \log(|a|)}{k^2+\varepsilon^2}\\\\
\psi^{(2)}_\varepsilon(k)&=-4\int_0^\infty \frac{|k|xe^{-\varepsilon |a|x}\sin(|ak|x)}{(x^2+1)(k^2+\varepsilon^2)}\,dx\\\\
\psi^{(3)}_\varepsilon(k)&=4\int_0^\infty \frac{\varepsilon x e^{-\varepsilon |a|x}\cos(|ak|x)}{(x^2+1)(k^2+\varepsilon^2)}\,dx
\end{align}$$

NOTE:
In going from $(3)$ to $(4)$, we took the real part, enforced the substitution $x\mapsto |a|x$, and integrated by parts with $u=\log(x^2+1)$ and $\displaystyle v=-\frac{e^{-\varepsilon |a| x}(|k|\sin(|ak|x)-\varepsilon \cos(|ak|x))}{|a|(k^2+a^2)}$.

Next, we will find the distributional limits of $\psi^{(1)}_\varepsilon$,  $\psi^{(2)}_\varepsilon$, and $\psi^{(3)}_\varepsilon$.

DISTRIBUTIONAL LIMITS OF $\displaystyle \psi^{(1)}_\varepsilon$,  $\displaystyle  \psi^{(2)}_\varepsilon$, and $\displaystyle  \psi^{(3)}_\varepsilon$

Let $\phi\in \mathbb{S}$.  Then, the distributional limit of $\psi^{(1)}_\varepsilon$ is
$$\begin{align}
\lim_{\varepsilon\to  0^+}\langle \psi^{(1)}_\varepsilon, \phi\rangle &=\lim_{\varepsilon\to  0^+}\int_{-\infty}^\infty \phi(k) \frac{4\varepsilon \log(|a|)}{k^2+\varepsilon^2}\,dk\\\\
&=\lim_{\varepsilon\to  0^+} \int_{-\infty}^\infty \phi(\varepsilon k)\frac{4\log(|a|)}{k^2+1}\,dk\\\\
&=4\pi \log(|a|)\phi(0)\tag5
\end{align}$$
where we applied the Dominated Convergence Theorem to arrive at $(5)$.

Choose any $\nu >0$.  Then, the distributional limit of $\psi^{(2)}_\varepsilon+\psi^{(3)}_\varepsilon$ is
$$\begin{align}
\lim_{\varepsilon\to  0^+}\langle \psi^{(2)}_\varepsilon+\psi^{(3)}_\varepsilon, \phi\rangle &=\lim_{\varepsilon\to  0^+}\int_{-\infty}^\infty \phi(k)\psi^{(2)}_\varepsilon(k) \,dk \\\\
&=\lim_{\varepsilon\to  0^+} \int_{-\infty}^\infty \left(\phi(k)-\phi(0)\xi_{[-\nu,\nu]}(k)\right)\psi^{(2)}_\varepsilon(k) \,dk\\\\
&+\lim_{\varepsilon\to  0^+} \int_{-\infty}^\infty \left(\phi(k)-\phi(0)\xi_{[-\nu,\nu]}(k)\right)\psi^{(3)}_\varepsilon(k) \,dk\\\\
&+\phi(0)\lim_{\varepsilon\to  0^+}\int_{-\nu}^\nu (\psi^{(2)}_\varepsilon(k)+\psi^{(3)}_\varepsilon(k)) \,dk\tag6
\end{align}$$
where in $(6)$, $\xi_{[-\nu,\nu]}(k)$ is the indicator function.
To evaluate the limit of third integral on the right-hand side of $(6)$, we write
$$\begin{align}
\lim_{\varepsilon\to 0^+}\int_{-\nu}^\nu (\psi^{(2)}_\varepsilon(k)+\psi^{(3)}_\varepsilon(k)) \,dk&=4\lim_{\varepsilon\to 0^+}\int_0^\infty e^{-\varepsilon |a|x}\log(x^2+1)\frac{\sin(|a|\nu x)}{kx}\,dx\tag7\\\\
&=4\int_0^\infty \log(x^2+1)\frac{\sin(|a|\nu x)}{x}\,dx\tag8\\\\
&=-4\pi \text{Ei}(-|a|\nu)\tag9
\end{align}$$

NOTE:
In going from $(7)$ to $(8)$ we justified interchanging the limit with the integral appealing to the result in This Answer).  In going from $(8)$ to $(9)$ we used Feynman's Trick by introducing a parameter $b$ (i.e., $\log(x^2+b)$), applied the residue theorem, and used $\lim_{|a|\to \infty}\int_0^\infty \log(x^2+1)\frac{\sin(|a|\nu x)}{x}\,dx=0$, which can be shown using integration by parts.

It is straightforward to evaluate the limit of second integral on the right-hand side of $(6)$ and find that
$$\begin{align}
\lim_{\varepsilon\to  0^+} \int_{-\infty}^\infty \left(\phi(k)-\phi(0)\xi_{[-\nu,\nu]}(k)\right)\psi^{(3)}_\varepsilon(k) \,dk=0
\end{align}$$

Next, it is straightforward to evaluate the limit of first integral on the right-hand side of $(6)$, we denote $I_\nu(a)$. and find that
$$\begin{align}
I_\nu(a)&=\lim_{\varepsilon\to  0^+} \int_{-\infty}^\infty \left(\phi(k)-\phi(0)\xi_{[-\nu,\nu]}(k)\right)\psi^{(2)}_\varepsilon(k) \,dk\\\\
&=-4\int_{-\infty}^\infty \frac{\phi(k)-\phi(0)\xi_{[-\nu,\nu]}(k)}{|k|}\int_0^\infty \frac{x\sin(|ak|x)}{x^2+1}\,dx\,dk\\\\
&=-2\pi \int_0^\infty \left(\phi(k)-\phi(0)\xi_{[-\nu,\nu]}(k)\right) \frac{e^{-|ak|}}{|k|}\,dk\tag{10}
\end{align}$$


Finally, using $(5)$, $(6)$, $(9)$ and $(10)$ yields
$$\bbox[5px,border:2px solid #C0A000]{\mathscr{F}\{\psi\}(k)=4\pi (\log(|a|)-\text{Ei}(-|\nu a|))\delta(k)-2\pi \left(\frac{e^{-{|ak|}}}{|k|}\right)_\nu}$$
where the distribution $\left(\frac{e^{-|ak|}}{|k|}\right)_\nu$ is defined by its action on any $\phi\in \mathbb{S}$
$$\int_{-\infty}^\infty \left(\frac{e^{-|ak|}}{|k|}\right)_\nu\phi(k)\,dk=\int_{-\infty}^\infty \left(\phi(k)-\phi(0)\xi_{[-\nu,\nu]}(k)\right)\frac{e^{-|ak|}}{|k|}\,dk$$
And for an even function $f$, we define the Fourier cosine transform as $1/2$ the Fourier transform $f$.  That is, we have
$$\bbox[5px,border:2px solid #C0A000]{\mathscr{F}_C\{\psi\}(u)=2\pi (\log(|a|-\text{Ei}(-|\nu a|)))\delta(u)-\pi \left(\frac{e^{-{|au|}}}{|u|}\right)_1}$$


NOTE:
For $\nu=1$ and $a\to 0$,  $-4\pi (\log(|a|)-\text{Ei}(-\nu |a|))\to -4\pi \gamma$, which agrees with the results in the THIS ANSWER and THIS ONE for the Fourier Transform of $\log(|x|)$.
