Surround logging in try catch to avoid encoding problem