So, this is probably a stupid question, but it has been a little bit since I took calculus, and have forgotten some of the specifics. I tried researching this, but for whatever reason I couldn't find anything. I'm pretty sure this is illegal, but if it isn't it turns this problem from nearly impossible to fairly easy, which I know is usually a sign that you are doing something wrong.
Here is what I tried to do
Thanks for any help, just a "yeah that's fine" or "no, you idiot" is sufficient!

You can't interchange the $\log$ function with integration. Observe \begin{align} \log\left(\int^\infty_0 e^{-x}\ dx \right) = \log\left(1\right) = 0 \end{align} but \begin{align} \int^\infty_0 \log e^{-x}\ dx=\int^\infty_0 -x\ dx = -\infty. \end{align}