Different configuration options to turn logging On/Off for explicit entities and users
For integrating the Logging Framework, following are the configuration options using which we can turn logging on or off for explicit entities and users:
The common thing that needs to be added to see logging on or off for explicit entities and users is,
<add key="serilog:using:FilterExpressions" value="Serilog.Filters.Expressions" />
- To turn logging On/Off for explicit entities or classes,
- To turn On, add the following configuration keys,
<add key="serilog:filter:ByIncluding.expression" value="SourceContext = 'GenericEntity'" />
Where 'Generic entity' is just an example of a class name for which you want to see logging. - To turn it Off, you just need to remove the above-mentioned configuration key from the file.
- To turn On, add the following configuration keys,
- Turn logging On/Off for explicit users,
- To turn On, add the following configuration keys,
<add key="serilog:filter:ByIncluding.expression" value="UserName = 'TestUser'" />
Where 'TestUser' is just an example of a username for which you want to see logging. - To turn it Off, you just need to remove the above-mentioned configuration key from the file.
- To turn On, add the following configuration keys,
Customizing config options for Aptify specific items we put into the OutputTemplate
For customizing config options for Aptify specific items we put into the OutputTemplate, you can edit the below given configuration key in the file:
<add key="serilog:write-to:RollingFile.outputTemplate" value="[{Timestamp:hh:mm:ss}
{Level:u3}] [UserCredentials: {UserContext}] [ClassName:{SourceContext}] {Message}