Yes. It can be used for any function. However, it's usually not necessary.
In its general form, it produces an "obvious" result that makes it seem like it's a waste of time:
If #y=f(x)#, then #ln(y)=ln(f(x))#. Now differentiate both sides with respect to #x# to get, by the Chain Rule, #\frac{1}{y}\frac{dy}{dx}=\frac{1}{f(x)}f'(x)#. Now solve for #dy/dx# to get #dy/dx=y\cdot \frac{f'(x)}{f(x)}=f(x)\cdot \frac{f'(x)}{f(x)}=f'(x)#.
However, for certain kinds of examples, it's not a waste of time because it gives the answer when no other approach seems to work. This is especially true in situations where the property #ln(a^{b})=bln(a)# is helpful in reducing an "atypical" function to a product of two "typical" functions.
For example, if #y=f(x)=x^{x}#, then logarithmic differentiation must be used (this function is neither a power function nor an exponential function):
#y=x^{x}\Rightarrow ln(y)=ln(x^{x})=x\ln(x)\Rightarrow #
#\frac{1}{y}\frac{dy}{dx}=ln(x)+x\cdot\frac{1}{x}=ln(x)+1#
Hence, #\frac{dy}{dx}=y(ln(x)+1)=x^{x}(ln(x)+1)#