This question is inspired by a recent course I did on random matrix theory and also from common mistakes high-schoolers make in algebra :).
In random matrix theory, one often encounters somewhat intractable integrals involving a logarithmic term that are often made more amenable to analysis using the replica trick, that is, say, in the case of trying to find the expectation of logarithm of a partition function, $Z(x)$, one can use the identity:
$$\mathbb{E}\big[\log Z(x)\big] = \lim_{n\to 0} \frac{1}{n}\log \mathbb{E}\big[Z(x)\big]^n.$$
This helps to evaluate integral more easily because the partition function usually takes the form of an exponential multiplied by another function.
My question is much simpler than this. Under what conditions would it just justifiable, or through the use of what technique would it be possible that either of the following relations
$$ \int \exp(f(x)) dx = \exp\left(\int f(x) dx\right) $$
or
$$ \int \log(f(x)) dx = \log\left(\int f(x) dx\right) $$
holds. Here $f\in \mathbb{C}^{\infty}$ and the integral denotes the Riemann integral.