real analysis – Interval of $p$ that makes the $p$ power of a function integrable

For a measurable real-valued function $f$ on $(0,infty)$ let $P(f):={pin(0,infty):|f|^pinmathcal{L}^1(mathbb{R},mathcal{B},lambda)}$, where $mathcal{B}$ is the Borel $sigma$-algebra. Show that for every subinterval $J$ of $(0,infty)$, which may be open or closed on the left and on the right, there is some $f$ such that $P(f)=J$. Hint: Consider functions such as $x^a|log x|^b$ on $(0,1)$ and on $(1,infty)$, where $b=0$ unless $a=-1$.

I don’t understand the hint. $f(x)=x^anotinmathcal{L}^1(mathbb{R},mathcal{B},lambda)$ for any $a$. The log part is also not integrable:

begin{equation}
begin{split}
& int_0^infty x^{-1}|log x|^bdx \
= & int_0^infty |log x|^bdlog x \
= & int_0^1 (-log x)^bdlog x+int_1^infty (log x)^bdlog x \
= & int_{-infty}^0 (-x)^bdx+int_0^infty x^bdx \
= & -int_{-infty}^0 (-x)^bd(-x)+int_0^infty x^bdx \
= & -int_infty^0 x^bdx+int_0^infty x^bdx \
= & int_0^infty x^bdx+int_0^infty x^bdx \
end{split}
end{equation}

But for $J=(0,infty)$, I can find such a $f(x)$:
begin{equation}
f(x) = begin{cases}
x-1 &text{$1<xleq2$}\
3-x &text{$2<xleq3$}\
0 &text{otherwise}
end{cases}
end{equation}