To understand the generation mechanism of a hierarchy of multiscale vortices in a high-Reynolds-number turbulent boundary layer, we conduct direct numerical simulations and educe the hierarchy of vortices by applying a coarse-graining method to the simulated turbulent velocity field. When the Reynolds number is high enough for the premultiplied energy spectrum of the streamwise velocity component to show the second peak and for the energy spectrum to obey the $-5/3$ power law, small-scale vortices, that is, vortices sufficiently smaller than the height from the wall, in the log layer are generated predominantly by the stretching in strain-rate fields at larger scales rather than by the mean-flow stretching. In such a case, the twice-larger scale contributes most to the stretching of smaller-scale vortices. This generation mechanism of small-scale vortices is similar to the one observed in fully developed turbulence in a periodic cube and consistent with the picture of the energy cascade. On the other hand, large-scale vortices, that is, vortices as large as the height, are stretched and amplified directly by the mean flow. We show quantitative evidence of these scale-dependent generation mechanisms of vortices on the basis of numerical analyses of the scale-dependent enstrophy production rate. We also demonstrate concrete examples of the generation process of the hierarchy of multiscale vortices.