TITLE: Integrability of log of distance function
QUESTION [6 upvotes]: Let $E\subset B_1(0)\subset \mathbb{R}^n$ be a compact set s.t. $\lambda(E)=0$, where $\lambda$ is the Lebesgue measure, and $B_1(0)$ is the Euclidean unit ball centered at the origin. Is the following integral finite:
$$\int_{B_1(0)}-\log d(x,E)d\lambda(x)<\infty?$$
Although this question seems trivial, I have failed to find a reference to it or to variations of it in previous discussions. I was not able to come up with a counter-example nor a proof. I also asked in mathstackexchange a variation of it, but didn’t get a sufficient answer.
Thanks ahead

REPLY [7 votes]: The integral in question is finite for most sets of measure zero, but can diverge to $\infty$ for some sets.  An example in one dimension is obtained by constructing a Cantor set where at stage $k$ the middle $1/(k+1)$ proportion is removed from each of the   $2^{k-1}$ intervals obtained at stage $k-1$. Thus the $2^k$ intervals obtained at stage $k$ will   each have length $2^{-k}/(k+1)$. Therefore, each of the $2^k$ middle intervals removed in the next stage will have length $2^{-k}/[(k+1)(k+2)]$, and each of these will contribute at least $k/2$ times its length to the integral. Summing over $k$ gives a harmonic series which diverges. The example can be lifted to higher dimensions by taking a Cartesian product with a $n-1$ dimensional box.