Fix instability in core/TEST038

This change writes the log file of the background sqlci to
a temporary log file and then when the background sqlci is
finished, the temporary log file is appended to the test
file.

Change-Id: I8c04791783da1ef379a087d19a39f1ce725a0140
Closes-Bug: #1334298