With regularization we can compute this integral:
$Version
(*12.1.1 for Microsoft Windows (64-bit) (June 9, 2020)*)
sol = Integrate[Cos[x] Log[x^2 + 4]*x^-s, {x, 0, Infinity}, Assumptions -> s > 0]
Limit[sol[[1]], s -> 0] // FullSimplify
(* -(\[Pi]/E^2) *)
Or another way:
func = Cos[a x] Log[x^2 + 4](*Where a = 1 *)
InverseLaplaceTransform[
Integrate[LaplaceTransform[func, a, s], {x, 0, Infinity},
Assumptions -> s > 0], s, a] (*Can't compute Inverse Laplace Transform !*)
(* Input *)
Ok workaround:
$$\underset{t\to 0}{\text{lim}}\frac{\partial (2+s)^t}{\partial t}=\ln (2+s)$$
Then we have:
Limit[D[InverseLaplaceTransform[Pi*(2 + s)^t, s, a], t] /. a -> 1, t -> 0]
(*-(\[Pi]/E^2)*)