Can I take $\log$ on both sides of inequality such way?

You can take the logarithm on both sides of the inequality, if you know the numbers are positive. This produces $\log(f(n))\le \log(cn^k)$.

However $\log(cn^k)$ is not the same thing as $kc\log n$, so your second inequality doesn't follow. What you do have is $\log(cn^k) = \log(c) + k\log(n)$, so you can get $$ \log(f(n)) \le \log(c) + k\log(n)$$


yes you can since $log$ is an increasing function and hence preserves the inequality. the main condition is that both sides lies in the domain of $log$ i.e. they are positive
$$\log(f(n)) \leq \log [cn^k]=\log c+\log n^k=\log c+k\log n $$ If $c >1$ then $\log c>0$ and so $$\log(f(n)) \leq k\log n\leq kc\log n $$