The logarithmic law of the mean velocity is considered a fundamental feature of wall-bounded turbulent flows. The logarithmic velocity law is used widely to model the near-wall turbulence and to predict skin friction. Although classical scaling theory has been used to verify that the velocity profile in the overlap region follows the logarithmic behavior asymptotically, and thus recent experiments have attempted to assess the logarithmic law in large-scale facilities, there is a lack of understanding of the structural basis for the logarithmic law. Here, we show the logarithmic law by extracting the wall-attached structures of the streamwise velocity fluctuations through direct numerical simulation of turbulent pipe flow. The wall-attached structures exhibit self-similar behavior according to their height and have an inverse scale population density, reminiscent of Townsend's attached-eddy hypothesis. The wall-normal distributions of the streamwise velocity within the identified structures are conditionally averaged with respect to their height. The velocity profile is reconstructed by superimposing the velocity distributions of the objects that follow the inverse-scale population density. The indicator function of the resulting velocity profile shows a complete plateau for the high-speed structures due to their higher local Reynolds number. These findings provide strong evidence that the identified coherent structures are directly related to the logarithmic velocity law and serve as the structural basis for the inertial layer. Published under license by AIP Publishing.