concept log message in category .net

This is an excerpt from Manning's book Microservices in .NET Core: with examples in Nancy.
Figure 1.10. An OWIN web server with OWIN middleware and an OWIN web application on top. The web server delegates incoming requests to the layers above: in this case, the request-logging middleware, which writes a log message about the request and then delegates to the web application. To the web server, the middleware looks like an OWIN-compliant application; and to the application, the middleware looks like an OWIN-compliant web server.
![]()
In addition to monitoring each individual microservice, you also need to send out log messages regarding failures, errors, performance, and whatever else you need insight into. As discussed in chapter 6, you can introduce a centralized Logging microservice that receives log messages from all the other microservices, saves them (for example, in a search engine), and provides easy access to them through dashboards and search UIs (see figure 9.5). Again, you want to be able to easily set up each microservice to send log messages to the Logging microservice.
Traditional logging libraries treat log messages as simple strings, possibly with an exception attached, but we’ll use something better: a structured logging library named Serilog. The idea of structured logging is to allow log messages to contain structured data: a log message contains not only a flat message—like “something went wrong”—but also objects.
Serilog introduces a bit of syntax to log messages on top of .NET format strings. The extra syntax lets you give names to parameters and control whether a parameter’s value should be converted to a string with a .ToString() call, or whether the object should be included as a whole in the log message. Named parameters are enclosed in braces: for example, "{RequestTime}". You tell Serilog to include the entire value in the message by putting an @ in front of the name: "{@Request}". As with .NET format strings, you add formatting directives to parameters without a leading @.
For instance, you can use Serilog to send a log message like this, assuming that log is an object of the Serilog type Ilogger: