Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-182

LevelRangeFilter behavior doesn't match documentation; behavior and documentation are not as expected

    XMLWordPrintableJSON

Details

    Description

      The LevelRangeFilter's behavior doesn't match what the documentation says. Also, neither the current behavior nor the documentation seem right.

      The log4net SDK Reference documentation says this about log4net.Filter.LevelRangeFilter:

      "If there is a match between the range of priorities and the Level of the LoggingEvent, then the Decide method returns Accept in case the AcceptOnMatch option value is set to true, if it is false then Deny is returned. If there is no match, Deny is returned."

      The actual behavior seems to differ from this in the case of a match. If there is a match, it looks like the code returns Accept when AcceptOnMatch is true, and Neutral if AcceptOnMatch is false.

      I think both the documentation and behavior should be changed to the following:

      "If there is a match between the range of priorities and the Level of the LoggingEvent, then the Decide method returns Accept if the AcceptOnMatch option is true, and Deny if the AcceptOnMatch option is false. If there is no match, Neutral is returned."

      This behavior seems more natural. It also parallels the behavior of the LevelMatchFilter.

      I believe this can be fixed simply by swapping occurrences of FilterDecision.Deny and FilterDecision.Neutral in the code for LevelRangeFilter.Decide – and also adjusting the documentation as above.

      Thanks.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jerdonek Chris Jerdonek
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: