Inequality sign change with logarithm 
Why does the inequality sign change when applying a logarithm on both sides, with the base less than $1$?

I came across the following math which I solved if 2 ways,
$$
\left(\frac{1}{2}\right)^n < \frac{1}{4}\\
n\log\left(\frac{1}{2}\right)< \log\left(\frac{1}{4}\right)\\
-0.301n < -0.602 \\
n > 2
$$
The second method is,
$$
\left(\frac{1}{2}\right)^n < \frac{1}{4}\\
n\log_\left(\frac{1}{2}\right) \left(\frac{1}{2}\right)< \log_\left(\frac{1}{2}\right) \left(\frac{1}{4}\right)\\
n < 2 \\
$$
Now I know the first one is the correct answer, but what I don't understand why the second method failed to give the correct inequality. Could someone please explain?
Another general question would be, if instead of values they were variable, meaning instead if $\frac{1}{2}$ it was A, and instead of $\frac{1}{4}$ it was B, how would I attempt to solve it since, with the first method, I wouldn't know if $log\left(A\right)$ was negative or positive.

You are actually computing:
$$n \log \frac{1}{2} < \log \frac{1}{4}$$
$$\frac{n \log 1/2}{\log 1/2} \color{red}{>} \frac{\log 1/4}{\log 1/2}$$
since $\log \frac{1}{2}$ is negative, and multiplying / dividing by a negative number flips the sign. Since $f(x) = \log x$ is monotonically increasing ($x > 0$) and $\log 1 = 0$, when the base is less than $1$, $\log b$ is negative and you will need to flip the sign.
By the change of base formula, this is equivalent to:
$$n\log_\left(\frac{1}{2}\right) \left(\frac{1}{2}\right) > \log_\left(\frac{1}{2}\right) \left(\frac{1}{4}\right)$$
$$n > 2$$
as you have already said.
