Fix crash in the CompatLogger class.

Fixes #5961