Unstructured logging records application events as sequential free-form text rather than fields organized by a fixed schema. It is easy to view in a console or text editor, making recent entries convenient to inspect. section 7.2.6 section 7.3.1
Use unstructured logs with these practical expectations:
- Review recent failures quickly when their approximate time is known. section 7.3.1
- Search older or uncertain events with text tools such as Notepad Find or Linux grep. section 7.3.1
- Expect large, verbose files to become difficult to browse and query. section 7.3.1
- Add event IDs to exception entries when later filtering may matter, then consider structured providers or log-management tools. section 7.2.6 section 7.3.1
Logging an unhandled API exception
A Minimal API error endpoint can call app.Logger.LogError with an exception and the message "An unhandled exception occurred." Adding a custom Error_Get event ID makes related entries easier to identify, even though the output remains primarily text-oriented.
using MyBGList.Constants;
// ... nonrelevant code omitted
app.Logger.LogError(
CustomLogEvents.Error_Get, #1
exceptionHandler?.Error,
"An unhandled exception occurred.");
Browse the event-ID LogError listing to see how an exception record receives a named numeric identifier. section 7.2.6
