# How does the Weyl anomaly imply $\langle T^{\mu}_{\mu} \rangle \neq 0$

I want to consider the case of euclidean field theory in 2 dimensions with the action

$$S[\phi]=\int \! d^2\!x \sqrt{\det(g)}g^{\mu\nu}\partial_\mu\phi\partial_\nu\phi$$

which leads to a partition function

$$Z:=\int\mathcal{D}\phi e^{-S[\phi]}$$

where the integration measure depends on the metric $$g$$ since the normalization of eigenfunctions depends on $$g$$.

I often read the claim that

$$\langle T^{\mu\nu}(x)\rangle=\frac{2}{\sqrt{\det(g)}}\frac{\delta W}{\delta g_{\mu\nu}(x)} \tag{1}$$

so that, since the r.h.s. isn't traceless, the l.h.s. as well is not traceless. (Here W is the logarithm of the partition function.)

I learned, that for a functional of the fields, its expectation value is defined as

$$\langle F\rangle:=\frac{1}{Z}\int\mathcal{D}\phi F[\phi]e^{-S[\phi]}.$$

But in 2 dimensions (and for this action), the functional sending a field configuration to the trace of the energy momentum tensor at a point $$x$$ is identically the zero functional, so shouldn't $$\langle T^\mu_\mu(x)\rangle=\langle0\rangle=0$$?

Also: how does one arrive at (1)? When i tried to calculate the variation of $$W$$, I got, additionaly to the l.h.s. of (1), a contribution related to a change in the integration measure which is not zero and, most importantly, its trace is the trace of the r.h.s. of (1), which would render the argument, that the l.h.s. of (1) is not traceless since the r.h.s. of (1) isn't traceless, invalid.