Personally, I think Tkhunny's method is far better, as it will get you to the answer much faster, but your method will absolutely work. The only problem you encountered was not being careful about what base logarithm you used. If you take the log base 2 of both sides, you'll obtain:
\(\displaystyle
2^x = 5 \\
log_2(2^x) = log_2(5) \\
x = log_2(5) \\
x \approx 2.3219
\)
A sanity check reveals that \(\displaystyle 2^{2.3219} \approx 4.999\), which is close enough for rounding errors, so we can conclude that \(\displaystyle 2^{log_2(5)} = 5\) (A careful consideration of the definition of the logarithm should also make it obvious why this must be the case). On the other hand, if you use the natural logarithm (base e), you'll obtain:
\(\displaystyle
2^x = 5 \\
ln(2^x) = ln(5) \\
x \cdot ln(2) = ln(5) \\
x = \dfrac{ln(5)}{ln(2)}
\)
This turns out to be the definition of \(\displaystyle log_2(5)\), so the two agree. It's important to note the rule for logarithms of powers only "pulls out front" the exponent, rather than "isolating it." That is to say, for the logarithm in any base:
\(\displaystyle
log_y(2^x) = x \cdot log_y(2)
\)
It should be easy enough to see that the logarithm part "disappears" if and only if \(\displaystyle y = 2\), since \(\displaystyle log_x(x) = 1\) for any strictly positive x.