While trying to apply the residue theorem to a certain integral, I arrived at the following equality, where $a$ is real with $0<a<1$. (It appears to hold for randomly chosen $a$ near $1$, anyway; see this notebook.)
$$\begin{align*} I(a) &= \int_0^\infty \frac{\sqrt x \arctan x \log\left(1+x^2\right)}{a^2+x^2} \, dx \\ &= \frac\pi{2\sqrt{2a}} \left[(\log(1-a))^2 - (\log(1+a)^2) + 4 \int_0^a \frac{\log(a-x)-\log x}{\sqrt x\left(1-x^2\right)}\,dx\right] \end{align*}$$
As $a\to1$ from below, based on the closed form provided in the parent post, I know the LHS should converge to $I(1)=\sqrt2\,\pi\left(G+\dfrac{\pi^2}{12}+\dfrac\pi4\log2+\dfrac34(\log2)^2\right)\approx11.743$. As for the RHS, I naively thought that I could get away with splitting off some of the "obviously" convergent terms and factors,
$$\begin{align*} \lim_{a\to1^-}I(a) &= \frac\pi{2\sqrt2} \left[L - (\log2)^2 - 4 \int_0^1 \frac{\log x}{\sqrt x\left(1-x^2\right)}\,dx\right] \\ &= \frac\pi{2\sqrt2} \left[L+8G+\pi^2-(\log2)^2\right] \end{align*}$$
where $G$ is Catalan's constant, and manipulating the expression $L$ which denotes the titular one-sided limit,
$$L = \lim_{a\to1^-} \frac1{\sqrt a} \left[(\log(1-a))^2 + \int_0^a \frac{4 \log(a-x)}{\sqrt x\,\left(1-x^2\right)} \, dx\right].$$
The integral on the right diverges when $a=1$, but by rewriting $(\log(1-a))^2$ as a definite integral, I managed to join the terms on the RHS to recover what numerical evidence again suggests should be a convergent integral,
$$\begin{align*} L &= \lim_{a\to1^-} \frac1{\sqrt a} \int_0^a \left(\frac{4\log(a-x)}{\sqrt x\left(1-x^2\right)}-\frac{2\log(1-x)}{1-x}\right) \, dx \\ &= \lim_{a\to1^-} \int_0^1 \frac{8\log a+8\log\left(1-x^2\right)-4\sqrt a\,x\left(1+ax^2\right)\log\left(1-ax^2\right)}{1-a^2x^4} \, dx. \end{align*}$$
According to Mathematica,
$$L=-4G-\dfrac{\color{red}2\pi^2}3+\pi\log2+4(\log2)^2\approx-6.144$$
and this leads to the correct value of $I(1)$, whereas plugging $a=1$ directly gives
$$J = \int_0^1 \frac{8-4x\left(1+x^2\right)}{1-x^4} \log\left(1-x^2\right) \, dx = -4G-\frac{\pi^2}3+\pi\log2+4(\log2)^2 \approx -2.854.$$
How can I obtain the missing $-\dfrac{\pi^2}3$ term? Where is the flaw that leads to this discrepancy? My suspicion is that the interchange of limit and integral is illegal, but I don't know exactly why.
Based on @QuýNhân's comment, a workaround is to rewrite the limand as
$$\begin{align*} L &= \lim_{a\to1^-} \left[\int_0^1 \frac{8\log a+\left(8-4\sqrt a\,x\left(1+ax^2\right)\right)\log\left(1-ax^2\right)}{1-a^2x^4} \,dx\right. \\ &\qquad\qquad \left. {} + 8 \underbrace{\int_0^1 \frac{\log\left(1-x^2\right)-\log\left(1-ax^2\right)}{1-a^2x^4} \, dx}_{K(a)}\right] \\ &= J + 8 \lim_{a\to1^-} K(a) \end{align*}$$
The numerical results now work out as expected, so all that's left is to show the remaining limit is $-\dfrac{\pi^2}{24}$. I'm happy to accept an answer that does so, or one that outlines the details as to why the earlier limit-integral interchange is invalid, while the latter interchange and isolation of $J$ is fine.