add sql log,open it if necessary.
Merge pull request #309 from forumbyr/master

add sql log,open it if necessary.