Trace of integral trace-class operator I have seen many answers to the converse question (which seems to be difficult in general), but I would like to ask the following:
Let $T: L^2 \rightarrow L^2$ be a trace-class operator that is also an integral operator 
$$Tf = \int K(\cdot,y)f(y)dy.$$
Since $T$ is trace-class $\operatorname{tr}(T)$ exists. Now, I would like to ask: Under what conditions is this trace given by 
$$\operatorname{tr}(T)=\int K(x,x) dx.$$
In a way, continuity would presumably be a sufficient requirement to make sense out of this expression, but I could imagine that much more is known about this.
 A: As js21 says in the comnent, this is always the case if we understand a restriction $K(x,x)$ of the kernel $K(x,y)$ onto diagonal in appropriate way. In general, a square-summable function of two variables does not have a well-defined restriction to sets of zero measure, like diagonal. But the kernels of nuclear operators belong to a nice class of functions for which integrals against many singular measures, including the diagonal measure, are well-defined.
It is defined by Kellerer 
and recently studied from a different point of view in a series of papers of Vershik, Zatitskiy and myself. We called such functions 'virtually continuous', since an equivalent description is the following: there exist a set of full measure $X'\subset (X,\mu)$ and a certain separable metric $\rho$ on $X'$ (such that measure $\mu$ is Borel) for which $K(x,y)$ is equivalent to a continuous function on $(X',\rho)$. That is, the virtual continuity is defined without referring to any topology, but using only the measure and the direct product structure of the space. Our paper in Russian Mathematical Surveys contains the details on nuclear operators and virtual continuity, and the further paper in St. Petersburg Mathematical Journal explains the connection with another approach to the trace via averaging over the neighborhood of a diagonal.
