Add debug logger to try and track down #4422.