diff --git a/src/main/java/org/jboss/logmanager/WrappedExtLogRecord.java b/src/main/java/org/jboss/logmanager/WrappedExtLogRecord.java index 5ecd9175..5e79b18b 100644 --- a/src/main/java/org/jboss/logmanager/WrappedExtLogRecord.java +++ b/src/main/java/org/jboss/logmanager/WrappedExtLogRecord.java @@ -158,6 +158,12 @@ public void setMessage(final String message) { orig.setMessage(message); } + @Override + public void setMessage(String message, FormatStyle formatStyle) { + super.setMessage(message, formatStyle); + orig.setMessage(message); + } + public Object[] getParameters() { return orig.getParameters(); } diff --git a/src/test/java/org/jboss/logmanager/FilterTests.java b/src/test/java/org/jboss/logmanager/FilterTests.java index 3f006439..e881d5d3 100644 --- a/src/test/java/org/jboss/logmanager/FilterTests.java +++ b/src/test/java/org/jboss/logmanager/FilterTests.java @@ -506,6 +506,27 @@ public void substituteFilterExceptionNullMessageTest(){ assertEquals("null", logRecord.getFormattedMessage()); } + @Test + public void substitutionFilterWithLogRecord(){ + final AtomicReference result = new AtomicReference(); + 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()); + } + private static final class MessageCheckingHandler extends Handler {