Where are measurable functions not locally integrable?

Let $f : \mathbb R^n \rightarrow \mathbb R$ be a measurable function.

We know that $f$ is not necessarily locally integrable - but how hard can a measurable $f$ fail to be so? For example, is it true that $f$ is locally integrable outside of a negligible set $N \subset \mathbb R^n$?

Edit: In consideration of the comment by zhs, let me correct the phrasing of the question. I was originally wondering whether the 'singular' behaviour of a measurable function can be localized to a 'small' set.

A motivational example is $f(x) = 1/x$ over the real line. It is locally integrable in the complement of the origin. Hence, a conceivable phenomenon, which I had in mind originally when asking the question, could be that a measurable $f$ is integrable over open sets that are compactly contained in the complement of some negligible sets.


On $\mathbb R$ define $f(x) = 1/\sqrt x, 0<x<1,$ $f(x) = 0$ elsewhere. Let $q_1,q_2, \dots $ be the rationals. Define

$$F(x) = \sum_{k=1}^{\infty}\frac{f(x-q_k)}{2^k}.$$

Then $F:\mathbb R \to [0,\infty]$ is measurable, and the monotone convergence theorem implies $\int_{\mathbb R}F < \infty.$ Therefore $F(x) < \infty$ a.e. On the set where $F=\infty$ redefine $F$ to be $0.$ The function $F^2$ is then measurable from $\mathbb R$ to $[0,\infty)$ and satisfies $\int_I F^2 = \infty$ for every interval $I$ of positive length.