Adding database logging