  Logarithmic finite-size scaling of the O($n$) universality class at the upper
critical dimensionality ($d_c=4$) has a fundamental role in statistical and
condensed-matter physics and important applications in various experimental
systems. Here, we address this long-standing problem in the context of the
$n$-vector model ($n=1, 2, 3$) on periodic four-dimensional hypercubic
lattices. We establish an explicit scaling form for the free energy density,
which simultaneously consists of a scaling term for the Gaussian fixed point
and another term with multiplicative logarithmic corrections. In particular, we
conjecture that the critical two-point correlation $g(r,L)$, with $L$ the
linear size, exhibits a two-length behavior: following the behavior $r^{2-d_c}$
governed by Gaussian fixed point at shorter distance and entering a plateau at
larger distance whose height decays as $L^{-d_c/2}({\rm ln}L)^{\hat{p}}$ with
$\hat{p}=1/2$ a logarithmic correction exponent. Using extensive Monte Carlo
simulations, we provide complementary evidence for the predictions through the
finite-size scaling of observables including the two-point correlation, the
magnetic fluctuations at zero and non-zero Fourier modes, and the Binder
cumulant. Our work sheds light on the formulation of logarithmic finite-size
scaling and has practical applications in experimental systems.
