First, let's come up with a way to define the exponential and logarithm of a matrix.
Suppose that a matrix $M$ is diagonalizable, i.e., there exists a non-singular matrix $S$ and a diagonal matrix $D$ such that $M = SDS^{-1}$. Then for any integer $n$, it can be shown that $M^n = SD^nS^{-1}$.
This allows us to use the Taylor series to define the matrix exponential:
$$e^M = \sum_{k=0}^\infty \frac{1}{k!} M^k$$
$$= \sum_{k=0}^\infty \frac{1}{k!} SD^kS^{-1}$$
$$= S(\sum_{k=0}^\infty \frac{1}{k!} D^k)S^{-1}$$
$$= Se^DS^{-1}$$
where $e^D$ denotes a diagonal matrix where the individual diagonal elements are the exponentials of the corresponding elements in $D$.
We can similarly define $\ln{M} = S(\ln D)S^{-1}$. But note that $\ln D$ will be complex if $D$ contains any negative values. And $\ln D$ will be undefined if $D$ has any zeroes on its diagonal (i.e., if $M$ is singular).
If two matrices $A$ and $B$ are simultaneously diagonalizable, with $A = SDS^{-1}$ and $B = SES^{-1}$, then yes, it is true that $\ln AB = S(\ln D + \ln E)S^{-1} = S(\ln E + \ln D)S^{-1} = \ln BA$, and so the two matrices commute. But if they're not simultaneously diagonalizable, then they won't necessarily commute.