logger: replace invalid and undefined characters in encode error message

[shocker-ja:1228]

Reported by OBATA Akio. Thanks!!!