SourceContext is Serilog metadata that records the namespace or category of the class that originated a log event. Serilog stores it in the Properties column by default. section 7.4.5
Store SourceContext in SQL
Add a ColumnOptions collection with a SqlColumn whose ColumnName and PropertyName are both SourceContext and whose data type is NVarChar. Delete the existing LogEvents table, run the application, visit /BoardGame, and verify the regenerated table in SSMS. section 7.4.5
<propertykey='EventId'> #1
<structure type=''>
<property key='Id'>
50110 #2
</property>
</structure>
</property>
<property key='SourceContext'> #1
MyBGList.Controllers.BoardGamesController#2
</property>
A stored log event shows SourceContext as a simple property containing the originating controller namespace. section 7.4.5
Use SourceContext to:
- Identify which application namespace produced a record. section 7.4.5
- Filter or inspect application records separately from Microsoft.AspNetCore records through logging-level configuration. section 7.4.5
