Let f(x)=y=a^x

taking log(base a) of both sides we get

logy=x

f^-1(x)=logx

base other than a could also be taken.

So log was needed to find the inverse.

(Remember taking log creates some restrictions as log is a function.)

loga X=p (a is base)

then a^p=X

hope this helps