Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4Net configuration - LevelMatchFilter

As there are following levels in log4net

  • ALL
  • DEBUG
  • INFO
  • WARN
  • ERROR
  • FATAL
  • OFF

Can anyone please tell me in log4net how can I log only INFO & ERROR or DEBUG & ERROR? What I mean here is be able to log two different levels which are not in sequence?

I can't do if I use following because warning messages will be logged as well which I don't want:

<filter type="log4net.Filter.LevelRangeFilter">
    <acceptOnMatch value="true" />
    <levelMin value="INFO" />
    <levelMax value="ERROR" />
</filter>
like image 700
iffi Avatar asked Oct 11 '11 05:10

iffi


1 Answers

Use LevelMatchFilter in conjunction with DenyAllFilter:

<filter type="log4net.Filter.LevelMatchFilter">
  <acceptOnMatch value="true" />
  <levelToMatch  value="INFO" />
</filter>
<filter type="log4net.Filter.LevelMatchFilter">
  <acceptOnMatch value="true" />
  <levelToMatch  value="ERROR" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
like image 71
iffi Avatar answered Sep 25 '22 22:09

iffi