Fix database logging