Made logging thread safe.