Fixes and refactors log functionality
Merge pull request #4125 from yurydelendik/issue4111

Fixes and refactors log functionality