  General canonical bundle formula due to Kawamata and others has played
fundamental roles in algebraic geometry. We show that the canonical bundle
formula has analytic characterization in terms of fiberwise integration, which
confirms a folklore conjecture. The proof uses $L^2$ metrics and the valuative
equivalence of plurisubharmonic singularities. As an application, we identify
the singularity of the Ohsawa measure from a general $L^2$ extension theorem of
Demailly for log canonical pairs, in terms of the singularity in Kawamata's
subadjunction. As another application, we give a partial answer to a question
of Berndtsson on semipositivity theorems.
