Filtering events
Prerequisites:
Install abstractions module
Read about general log configuration practices
Read about log interface
Read about log events
Filtering allows a particular ILog instance to only record a subset of incoming log events. Events can be filtered by level, properties or literally any other information present.
Filter by level
Set a minimum allowed log level (events of lower levels will be dropped):
log = log.WithMinimumLevel(LogLevel.Warn);Selectively disable some log levels:
log = log.WithDisabledLevels(LogLevel.Debug, LogLevel.Fatal);Filter by a single property
Select events having a property with given name and a of given type value satisfying a predicate:
log = log.WithEventsSelectedByProperty<string>("prop", value => value == "foo");Drop events having a property with given name and a value of given type satisfying a predicate:
Filter by all properties
Select events whose properties dictionary satisfies given predicate:
Drop events whose properties dictionary satisfies given predicate:
Filter by source context
Select events having a source context with given value (values are case-insensitive prefixes):
Drop events having a source context with given value (values are case-insensitive prefixes):
Drop events below some level having a source context with given value (values are case-insensitive prefixes):
There's also an alternative syntax that allows to infer context values from type names:
Filter by arbitrary event content
Select events satisfying given predicate:
Drop events satisfying given predicate:
Last updated