  We find a class of optimal Sobolev inequalities
$$\Big(\int_{\mathbb{R}^N}|\nabla u|^2\, dx\Big)^{\frac{N}{N-2}}\geq
C_{N,G}\int_{\mathbb{R}^N}G(u)\, dx, \quad u\in\mathcal{D}^{1,2}(\mathbb{R}^N),
N\geq 3,$$ where the nonlinear function $G:\mathbb{R}\to\mathbb{R}$ of class
$\mathcal{C}^1$ satisfies general growth assumptions in the spirit of the
fundamental works of Berestycki and Lions. We admit, however, a wider class of
problems involving zero, positive and infinite mass cases as well as $G$ need
not be even. We show that any minimizer is radial up to a translation,
moreover, up to a dilation, it is a least energy solution of the nonlinear
scalar field equation $$-\Delta u = g(u)\quad \hbox{in
}\mathbb{R}^N,\quad\hbox{with }g=G'.$$ In particular, if $G(u)=u^2\log |u|$,
then the sharp constant is
$C_{N,G}:=2^*(\frac{N}{2})^{2^*}e^{\frac{2(N-1)}{N-2}}(\pi)^{\frac{N}{N-2}}$
and $u_\lambda(x)=e^{\frac{N-1}{2}-\frac{\lambda^2}{2}|x|^2}$ with $\lambda>0$
constitutes the whole family of minimizers up to translations. The optimal
inequality provides a new proof of the classical logarithmic Sobolev inequality
based on a Pohozaev manifold approach. Moreover, if $N\geq 4$, then there is at
least one nonradial solution and if, in addition, $N\neq 5$, then there are
infinitely many nonradial solutions of the nonlinear scalar field equation. The
energy functional associated with the problem may be infinite on
$\mathcal{D}^{1,2}(\mathbb{R}^N)$ and is not Fr\'echet differentiable in its
domain. We present a variational approach to this problem based on a new
variant of Lions' lemma in $\mathcal{D}^{1,2}(\mathbb{R}^N)$.
