Maintenance - We're currently working on things and you might experience some issues. Should be wrapped up soon!

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
How to properly log all info from a data model into a seq server using Serilog
Post Body

After a new contact has been created, I want to log all the info from the recently created contact into the seq server. Still trying to understand the whole concept of scoping.

Before, I was using string interpolation to do it.

//failed attempt with string interpolation
_logger.LogInformation($"Contact was created successfully.\n"  
                       $"{contact.FirstName} \n"  
                       $"{contact.LastName} \n"  
                       $"{contact.HomePhone} \n"  
                       $"{contact.MobilePhone} \n"  
                       $"{contact.PersonalEmail} \n"  
                       $"{contact.WorkEmail} \n"  
                       $"{contact.Address1} \n"  
                       $"{contact.Address2} \n"  
                       $"{contact.City} \n"  
                       $"{contact.State} \n"  
                       $"{contact.ZipCode} \n"  
                       $"{contact.Company} \n"  
                       $"{contact.FaxNumber} \n"
                       );

Failed attempt using string interpolation

//trying to implement Begin Scope
using (_logger.BeginScope(contact))
{
    //insert code here
}

I'm now attempting to use scoping but like stated earlier, I'm still not entirely sure how to implement it properly in terms of syntax. Was looking for help in order to properly log all properties of the contact model. I wanted some help when it comes to understanding scoping and how to log all properties in.

create a for loop and then log each individually, or is there an easier syntax for that?

Author
User Disabled
Account Strength
0%
Disabled 8 months ago
Account Age
4 years
Verified Email
Yes
Verified Flair
No
Total Karma
188
Link Karma
116
Comment Karma
72
Profile updated: 3 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago