Uploaded image for project: 'JBoss Log Manager'
  1. JBoss Log Manager
  2. LOGMGR-315

SubstituteFilter is not applied to WrappedExtLogRecord

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.1.20.Final, 3.0.0.Alpha1
    • None
    • None
    • None
    • Hide

      Test-Code for the org.jboss.logmanager.FilterTests :

       

      @Test
      public void substitutionFilterWithLogRecord(){
          final AtomicReference<String> result = new AtomicReference<String>();
          final Handler handler = new MessageCheckingHandler(result);
          final Logger logger = Logger.getLogger("filterTest");
          final Filter filter = new SubstituteFilter(Pattern.compile("test"),"lunch",true);
      
          logger.setUseParentHandlers(false);
          logger.addHandler(handler);
          logger.setLevel(Level.INFO);
          logger.setFilter(filter);
          handler.setLevel(Level.INFO);
      
          final LogRecord record = new LogRecord(Level.INFO,"{0}");
          record.setLoggerName("filterTest");
          record.setParameters(new Object[]{"test"});
      
          logger.log(record);
          assertEquals("The substitution was not correctly applied","lunch",result.get());
      } 
      Show
      Test-Code for the org.jboss.logmanager.FilterTests :   @Test public void substitutionFilterWithLogRecord(){ final AtomicReference< String > result = new AtomicReference< String >(); final Handler handler = new MessageCheckingHandler(result); final Logger logger = Logger.getLogger( "filterTest" ); final Filter filter = new SubstituteFilter(Pattern.compile( "test" ), "lunch" , true ); logger.setUseParentHandlers( false ); logger.addHandler(handler); logger.setLevel(Level.INFO); logger.setFilter(filter); handler.setLevel(Level.INFO); final LogRecord record = new LogRecord(Level.INFO, "{0}" ); record.setLoggerName( "filterTest" ); record.setParameters( new Object []{ "test" }); logger.log(record); assertEquals( "The substitution was not correctly applied" , "lunch" ,result.get()); }

      When using JUL-LogRecord with parameter substituion and applying the 
      SubstituteFilter only the message template (containing placeholders) will be logged.
       

      The problem is that LogRecords are wrapped in the WrappedExtLogRecord and the method

      ExtLogRecord#setMessage(final String message, final FormatStyle formatStyle) is not overloaded. The method is called by SubstituteFilter but the message is never delegated to the (original) wrapped LogRecord.

       

              jperkins-rhn James Perkins
              joachim.baeck@gmail.com Joachim Baeck (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: