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.
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?
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/csharp/comm...