Log database exception when it occurs.