how to see the logarithm as the inverse function of the exponential?
You want to understand that exponential and logarithms are inverse of each other:
(i)$ f(x) = y$, if we want to find the inverse, we express $x$ in terms of $y$. I will show you graphically.. (This is equally applicable for other exponents)
Which is one way of seeing that both are inverse of each other.
(ii) $a > 0$ and $x > 0$, condition $a \ne 1$, the logarithm base $a$ of $x$,
we write $\log_a(x)$, which is the exponent to which $a$ to be raised to obtain $y$. $\log_a(x) = y$, which is same as $a^y = x$. The functions $\log_a(x)$ and $a^x$ are clearly inverses of each other. The domain of logarithm base $a$ is all positive numbers and range is all real numbers.
Using the fact that the domain and range of any invertible function are just the range and domain of its inverse.
Here, the domain $\rightarrow$ logarithm base $a$ function is the range $\rightarrow$ $a^x$ function (remember for all positive no.)
and the range $\rightarrow$ logarithm base $a$ function is the domain $\rightarrow$ $a^x$ function (here it is for all numbers).
A simple way to state how they're related would be that one function will undo the other.
$$\log(e^x)=x$$ $$e^{\log x}=x$$
For a positive real number $\;a\neq 1\;$, we have by definition
$$a^y=x\iff \log_ax=y\;,\;\;x>0$$
In words: the logarithm in base $\;a\;$ of a positive number $\;x\;$ is the exponent to which the base must be raised in order to get $\;x\;$ .
Thus, for example, $\;\log_381=4\;$ since the base $\;3\;$ must be raised to the fourth power in order to get $\;81\;$.
Once one swallows and assimilates this, the tight relation between logarithms and exponentials becomes much clearer. For example:
$$\begin{cases}&\log_3x=y&\iff 3^y=x\\{}\\ &3^y=x&\iff \log_3x=y\end{cases}$$
and from this is now clear that $\;f(x):=\log_ax\;,\;\;g(x):=a^x\;$ are inverse functions to each other, meaning:
$$f\circ g(x)=f(g(x))=\log_a(a^x)=x=3^{\log_ax}=g(f(x))=g\circ f(x)$$