Skip to content

Configure Filters

Khaos edited this page Apr 28, 2021 · 4 revisions

Filter

<Serilog>
  <Using>Serilog.Expressions</Using>
  <Filter Name="ByIncludingOnly">
    <Expression>Prop = 42</Expression>
  </Filter>
</Serilog>

For filters see Serilog.Expressions or Serilog.Filters.Expressions

Custom Filter

<Serilog>
  <Using>Your.Assembly</Using>
  <Filter Name="With">
    <Filter>Your.Namespace.YourFilter, YourAssembly</Filter>
  </Filter>
</Serilog>

Filter with Switch

Requires Serilog.Expressions or Serilog.Filters.Expressions

<Serilog>
  <Using>Serilog.Expressions</Using>
  <FilterSwitches>
    <Switch Name="MySwitch" Expression="Prop = 42" />
  </FilterSwitches>
  <Filter ControlledBy="MySwitch"/>
</Serilog>

or

<Serilog>
  <Using>Serilog.Expressions</Using>
  <FilterSwitches>
    <Switch Name="MySwitch">Prop = 42</Switch>
  </FilterSwitches>
  <Filter Name="ControlledBy">
    <Switch>MySwitch</Switch>
  </Filter>
</Serilog>
Clone this wiki locally