Logging for documents retrieved from database, updated version.