Consider a diffusion process:

$ \text{d}X_t = f(X_t)\text{d}t + \text{d}W_t$

I've seen it given that the log-likelihood of the path is proportional to the Onsager-Machlup functional

$ \int_0^T \left(\frac{1}{2} \left|\dot{x}-f(x)\right|^2+\frac{1}{2}\nabla_x\cdot f(x)\right)\text{d}t$.

Where does the second term with the divergence come from? I think I once knew this ... is it something to do with the interpretation of $\dot{x}$ or the commutator $[x,\dot{x}]$?

The expression can be found, for example, in p. 5 section 3.1 of Hairer et al, "A Bayesian approach to Data Assimilation" http://www.hairer.org/papers/bayesian.pdf.