You can define your own function to do so:
realIntegrate[f_, x_Symbol] :=
Simplify[Integrate[f, x] /. Log[expr_] :> Log[Abs[expr]], x ∈ Reals]
realIntegrate[1/x, x]
(* Log[Abs[x]] *)
realIntegrate[2x/(x^2 - 1), x]
(* Log[Abs[x^2 - 1]] *)
realIntegrate[2x/(x^2 + 1), x]
(* Log[x^2 + 1] *)
Or if you need Integrate to do this, you can overload its definition:
Unprotect[Integrate];
Integrate[f_, x_Symbol] /; !TrueQ[$flag] :=
Block[{$flag = True},
realIntegrate[f, x]
]
Protect[Integrate];
Integrate[1/x, x]
(* Log[Abs[x]] *)
Integrate[2x/(x^2 - 1), x]
(* Log[Abs[x^2 - 1]] *)
Integrate[2x/(x^2 + 1), x]
(* Log[x^2 + 1] *)
Logits answer is correct for negative values. If you can explain the problem Mathematica's answer gives you, we may be able to suggest a work around. – mikado Oct 29 '17 at 13:49