Database logging improvements