Loupe supports a distinct Caption & Description text field for a message while MEL uses only a single message field. In this scenario, Loupe looks for the first Carriage Return (\r) or Line Feed (\f) and treats the message up to that as the caption and everything after that as the description.
This is particularly important for Critical, Error, and Warning messages as the caption is part of how Loupe groups log messages together into events. So, if a log messages use insertion stings it's important to be cautious about doing that before the first CRLF so the message isn't overly unique.
For example, don't insert any of these things before the first CRLF:
- Timestamp or Date (Note: Loupe adds the message timestamp automatically)
- IP Address
- URL
- File Name
- File Size or Position
Any of these can be put in the description without issue.
Some things make sense to be put in the first line because they definitely should be considered part of the event - like an exception type.
Example Optimized Messages |
Copy Code
|
---|---|
logger.LogCritical(ex, "Unable to keep running this application due to an {Exception}\r\n" + "Now that we're on the second line, here's more information we can share " + "that won't cause an overly-unique message: " + "{Order}, {OrderQuantity:N0}, {OrderTimestamp:g}", ex.GetType().Name, firstVal, secondVal, thirdVal); logger.LogError(ex, "Unable to complete the action we were performing due to an {Exception}\r\n" + "Errors are for when the current activity can't complete successfully but the " + "application can continue to process requests.", ex.GetType().Name); logger.LogWarning(ex, "It is very suspicious that we caught an {Exception}\r\n" + "Since we think we can handle this and continue with the current activity " + "(perhaps by doing a retry) we won't record it as an error.", ex.GetType().Name); logger.LogInformation( "For an Informational message or lower we don't need to worry about putting " + "items in the caption: {Order}, {OrderQuantity:N0}, {OrderTimestamp:g}\r\n" + "You can still can have a description field where you go wild with additional " + "detail but it's often useful to put distinct information in the caption " + "to help in finding the right activity.", firstVal, secondVal, thirdVal); |