Note that, with the substitution $x \mapsto nx$, we have
$$ \frac{f(n)}{n} = \int_{0}^{\infty} \log^2 \left( \frac{x + 1}{x + n^{-2}} \right) \, dx. $$
Now, let us denote
$$ h_n (x) = \log^2 \left( \frac{x + 1}{x + n^{-2}} \right) \quad \text{and} \quad h(x) = \log^2 \left( \frac{x + 1}{x} \right). $$
Then we easily observe that
- $h_n (x) \to h(x)$ pointwise and $h_n (x) \leq h(x)$. Indeed,
$$ 1 \leq \frac{x+1}{x+n^{-2}} \leq \frac{x+1}{x} $$
and the claim follows by observing that $x \mapsto \log^2 x$ is non-negative increasing on $x \geq 1$.
- $h(x)$ is integrable. It is a direct consequence of the following estimation:
\begin{align*}
\int_{0}^{\infty} h(x) \, dx
&= \int_{0}^{1} h(x) \, dx + \int_{1}^{\infty} h(x) \, dx \\
&= \int_{1}^{\infty} \frac{h(1/x)}{x^2} \, dx + \int_{1}^{\infty} h(x) \, dx \\
&= \int_{1}^{\infty} \frac{\log^2 (1+x)}{x^2} \, dx + \int_{1}^{\infty} \log^2 \left(1 + \frac{1}{x} \right) \, dx \\
&\leq \int_{1}^{\infty} \frac{\log^2 (1+x)}{x^2} \, dx + \int_{1}^{\infty} \frac{dx}{x^2}
< \infty.
\end{align*}
Then by dominated convergence we obtain
$$ \frac{f(n)}{n} = \int_{0}^{\infty} h_n(x) \, dx \xrightarrow[]{n\to\infty} \int_{0}^{\infty} h(x) \, dx. $$
(If you want to avoid the use of dominated convergence, which requires some basic measure theory, you can first show that $h_n(x) \uparrow h(x)$ as $n \to \infty$ pointwise. Then by Dini's theorem, on any compact subset of $(0, \infty)$ we have $h_n (x) \to h(x)$ uniformly. Now a suitable $\epsilon-\delta$ argument will give the same conclusion.)
This already shows that
$$ f(x) \sim cn $$
for some constant $c > 0$. To determine the constant $c$, we have to show that
$$ \int_{0}^{\infty} h(x) \, dx = \frac{\pi^2}{3}. $$
But this is also straightforward. Indeed, put $\displaystyle u = \frac{x}{x+1}$. Then $\displaystyle dx = \frac{du}{(1-u)^2}$ and therefore
\begin{align*}
\int_{0}^{\infty} h(x) \, dx
&= \int_{0}^{\infty} \log^2 \left( \frac{x + 1}{x} \right) \, dx
= \int_{0}^{1} \frac{\log^2 u}{(1-u)^2} \, du \\
&= \left[ \frac{u}{1-u} \log^2 u \right]_{0}^{1} - 2 \int_{0}^{1} \frac{\log u}{1-u} \, du \\
&= 2 \int_{0}^{\infty} \frac{t}{e^{t}-1} \, dt \qquad (u = e^{-t}) \\
&= 2 \zeta(2) = \frac{\pi^2}{3}.
\end{align*}