If you are using version 11.1 or later you can define
g[x_] = x*Log[RealAbs[x]]
Otherwise use Piecewise to avoid that derivative of g be calculated on the complexes.
Piecewise
g