Table of Contents

Use log message templates to allow structured logging

Instead of

logger.LogInformation($"New order {orderNumber} for customer {customer}");

log the message like this

logger.LogInformation("New order {orderNumber} for customer {customer}", orderNumber, customer);

This allows for easier querying and filtering of log entries based on specific fields. Which means that we can do things like: - Show all log entries for the template Receiving order {orderNumber} for customer {customerNumber}. Regardless of which order number or customer number was logged. - Show all log entries for a specific order number. This includes but is not limited to the template. - Show all log entries for a specific customer number. This include but is not limited to the template.

References

© 2024 Rob van der Velden. All rights reserved.