Fix some null pointer exceptions in logging