Implement database logging