Fixing null pointer exception in logger