How to show hostname instead of ip in query log?

Made an FAQ about this: