We report on experimental determinations of the temperature field in the interior (bulk) of turbulent Rayleigh–Bénard convection for a cylindrical sample with an aspect ratio (diameter $\def \xmlpi #1{}\def \mathsfbi #1{\boldsymbol {\mathsf {#1}}}\let \le =\leqslant \let \leq =\leqslant \let \ge =\geqslant \let \geq =\geqslant \def \Pr {\mathit {Pr}}\def \Fr {\mathit {Fr}}\def \Rey {\mathit {Re}}D$ over height $L$) equal to 0.50, in both the classical and the ultimate state. The measurements are for Rayleigh numbers $\mathit{Ra}$ from $6\times 10^{11}$ to $10^{13}$ in the classical and $7\times 10^{14}$ to $1.1\times 10^{15}$ (our maximum accessible $\mathit{Ra}$) in the ultimate state. The Prandtl number was close to 0.8. Although to lowest order the bulk is often assumed to be isothermal in the time average, we found a ‘logarithmic layer’ (as reported briefly by Ahlers et al., Phys. Rev. Lett., vol. 109, 2012, 114501) in which the reduced temperature $\varTheta = [\langle T(z) \rangle - T_m]/\Delta T$ (with $T_m$ the mean temperature, $\Delta T$ the applied temperature difference and $\langle {\cdots } \rangle $ a time average) varies as $A \ln (z/L) + B$ or $A^{\prime } \ln (1-z/L) + B^{\prime }$ with the distance $z$ from the bottom plate of the sample. In the classical state, the amplitudes $-A$ and $A^{\prime }$ are equal within our resolution, while in the ultimate state there is a small difference, with $-A/A^{\prime } \simeq 0.95$. For the classical state, the width of the log layer is approximately $0.1L$, the same near the top and the bottom plate as expected for a system with reflection symmetry about its horizontal midplane. For the ultimate state, the log-layer width is larger, extending through most of the sample, and slightly asymmetric about the midplane. Both amplitudes $A$ and $A^{\prime }$ vary with radial position $r$, and this variation can be described well by $A = A_0 [(R - r)/R]^{-0.65}$, where $R$ is the radius of the sample. In the classical state, these results are in good agreement with direct numerical simulations (DNS) for $\mathit{Ra} = 2\times 10^{12}$; in the ultimate state there are as yet no DNS. The amplitudes $-A$ and $A^{\prime }$ varied as ${\mathit{Ra}}^{-\eta }$, with $\eta \simeq 0.12$ in the classical and $\eta \simeq 0.18$ in the ultimate state. A close analogy between the temperature field in the classical state and the ‘law of the wall’ for the time-averaged downstream velocity in shear flow is discussed. A two-sublayer mean-field model of the temperature profile in the classical state was analysed and yielded a logarithmic $z$ dependence of $\varTheta $. The $\mathit{Ra}$ dependence of the amplitude $A$ given by the model corresponds to an exponent $\eta _{th} = 0.106$, in good agreement with the experiment. In the ultimate state the experimental result $\eta \simeq 0.18$ differs from the prediction $\eta _{th} \simeq 0.043$ by Grossmann & Lohse (Phys. Fluids, vol. 24, 2012, 125103).