http://en.wikipedia.org/wiki/Time_complexity#Polynomial_time
An algorithm is said to be of polynomial time if its running time is upper bounded by a polynomial expression in the size of the input for the algorithm
$O(log(n))$ is upper bounded by $O(n)$, and $O(n*log(n))$ is upper bounded by $O(n^2)$, therefore they are both in $P$.