Questions
- Is the following code snippet correct? How would you improve it?
var foo = 42;
var bar = "bar";
logger.LogInformation($"hello world: {foo}, {bar}");
- Let’s say your application writes usage events using the
ILogger
APIs. Events are exported somewhere and then used to build business-critical reports. As your application evolves, you will probably refactor code, rename namespaces and classes, improve log messages, and add more arguments. How can you write logs to keep the usage report resilient to logging changes? - Assuming that traces for HTTP requests are collected, do you also need to write logs for the same HTTP calls?