Fix logging NullPointerException