diff --git a/src/main/java/org/jboss/logmanager/filters/RegexFilter.java b/src/main/java/org/jboss/logmanager/filters/RegexFilter.java index ee4e71a3..60b7d267 100644 --- a/src/main/java/org/jboss/logmanager/filters/RegexFilter.java +++ b/src/main/java/org/jboss/logmanager/filters/RegexFilter.java @@ -59,9 +59,12 @@ public RegexFilter(final String patternString) { */ @Override public boolean isLoggable(final LogRecord record) { + final String msg; if (record instanceof ExtLogRecord) { - return pattern.matcher(((ExtLogRecord) record).getFormattedMessage()).find(); + msg = ((ExtLogRecord) record).getFormattedMessage(); + } else { + msg = record.getMessage(); } - return pattern.matcher(record.getMessage()).find(); + return pattern.matcher(String.valueOf(msg)).find(); } } diff --git a/src/main/java/org/jboss/logmanager/filters/SubstituteFilter.java b/src/main/java/org/jboss/logmanager/filters/SubstituteFilter.java index efc083f4..98b5a617 100644 --- a/src/main/java/org/jboss/logmanager/filters/SubstituteFilter.java +++ b/src/main/java/org/jboss/logmanager/filters/SubstituteFilter.java @@ -73,12 +73,13 @@ public SubstituteFilter(final String patternString, final String replacement, fi */ @Override public boolean isLoggable(final LogRecord record) { - final Matcher matcher; + final String currentMsg; if (record instanceof ExtLogRecord) { - matcher = pattern.matcher(((ExtLogRecord) record).getFormattedMessage()); + currentMsg = ((ExtLogRecord) record).getFormattedMessage(); } else { - matcher = pattern.matcher(record.getMessage()); + currentMsg = record.getMessage(); } + final Matcher matcher = pattern.matcher(String.valueOf(currentMsg)); final String msg; if (replaceAll) { msg = matcher.replaceAll(replacement);