How do you prove that $\ln|f(z)|$ is harmonic?

Suppose that $f(z)$ is analytic and nonzero in a domain $D$. Prove that $\ln|f(z)|$ is harmonic in $D$.

I know the laplacian equation but I'm not sure how to use it.


EDIT: As 5pm points out below, this is of course actually good enough since every domain in $\mathbb{C}$ is locally simply connected and harmonicity is a local property!

This was too long for a comment, but I thought it might be nice to know.

There is a much nicer, less computational way to prove this result if we assume further that $D$ is simply connected. In particular, recall that if $D$ is a simply connected domain in $\mathbb{C}$ and $h$ a non-vanishing holomorphic function on $D$ then $h=e^g$ for some holomorphic function $g$ (this is because we can define a branch of the logarithm on $D$).

So, if $D$ was simply connected we'd know that $f=e^g$ for some holomorphic $g$, and then

$$\log|f|=\log|e^g|=\log(\exp(\text{Re}(g))=\text{Re}(g)$$

and since $g$ is harmonic (since $g$ was holomorphic!) we're done.


Note: here is how you can prove this at the very beginning of a complex analysis course. Once you know how to define branches of log, Alex's approach is recommended.

Recall that analyticity is characterized by the Cauchy Riemann equation $$ \frac{\partial f}{\partial \bar{z}}=0=\frac{\partial \bar{f}}{\partial z} $$ and that the Laplacian satisfies $$ \Delta=4\frac{\partial^2}{\partial z\partial \bar{z}}. $$

Now differentiate $$ \frac{\partial}{\partial \bar{z}}\log (f\bar{f})=\frac{1}{f\bar{f}}\left(\frac{\partial f}{\partial \bar{z}} \bar{f}+f \frac{\partial \bar{f}}{\partial \bar{z}} \right)=\frac{1}{\bar{f}}\frac{\partial \bar{f}}{\partial \bar{z}} $$ and differentiate once more $$ \frac{\partial^2}{\partial z\partial \bar{z}}\log(f\bar{f})=\frac{-\frac{\partial \bar{f}}{\partial z}}{\bar{f}^2}\frac{\partial \bar{f}}{\partial \bar{z}}+\frac{1}{\bar{f}}\frac{\partial^2}{\partial z\partial \bar{z}}\bar{f}=\frac{1}{\bar{f}}\frac{\partial^2}{\partial \bar{z}\partial z}\bar{f}=0. $$

So $$\log |f|=\frac{1}{2}\log |f|^2=\frac{1}{2}\log (f\bar{f})$$ is harmonic.

Note: all the cancellations are due to the Cauchy-Riemann equation.