Adding logging support. Work in progress.