Preserve exception when logging, as suggested by S.

Change-Id: I6a9f189c3d7d515b530cdc3f811d0b05c8230529
Merge "Preserve exception when logging, as suggested by S."