Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-499

MarkerFilter doesn't recognize nested markers.

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.0.4
    • 0.9.29
    • logback-classic
    • None
    • MacOsx, Jdk 1.6 update 26

    Description

      I was trying to use nested markers to organize my logs in a better (maybe) way.
      But the MarkerFilter (ch.qos.logback.classic.turbo.MarkerFilter) did not treat nested (or composite) markers as I expect.

      Here a test that shows this issue, this test can be appended to ch.qos.logback.classic.turbo.MarkerFilterTest:

      @Test
      public void testComposite()

      { String compositeMarkerName = "compositeMarker"; Marker compositeMarker=MarkerFactory.getMarker(compositeMarkerName); compositeMarker.add(totoMarker); MarkerFilter mkt = new MarkerFilter(); mkt.setMarker(MARKER_NAME); mkt.setOnMatch("ACCEPT"); mkt.setOnMismatch("DENY"); mkt.start(); assertTrue(mkt.isStarted()); assertEquals(FilterReply.DENY, mkt.decide(null, null, null, null, null, null)); assertEquals(FilterReply.ACCEPT, mkt.decide(totoMarker, null, null, null, null, null)); assertEquals(FilterReply.ACCEPT, mkt.decide(compositeMarker, null, null, null, null, null)); }

      The solution that I found is pretty simple, here is the patch:

      diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java
      index 8e133cb..434b035 100644
      — a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java
      +++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java
      @@ -47,7 +47,7 @@ public class MarkerFilter extends MatchingFilter

      { return onMismatch; }

      • if(markerToMatch.contains(marker)) {
        + if(marker.contains(markerToMatch)) { return onMatch; }

        else {
        return onMismatch;


        • 1.7.5.4

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            pmazzoncini Paolo Mazzoncini
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: