Skip to content

Commit

Permalink
fix: also check exceptions/stack trace when filtering log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterchen09 committed May 26, 2024
1 parent 4d9b681 commit 98b4709
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.linkedin.metadata.utils.log;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.ThrowableProxyUtil;
import ch.qos.logback.core.filter.AbstractMatcherFilter;
import ch.qos.logback.core.spi.FilterReply;
import java.util.ArrayList;
Expand All @@ -21,7 +23,21 @@ public FilterReply decide(ILoggingEvent event) {
return FilterReply.NEUTRAL;
}

if (this.excluded.stream().anyMatch(message -> event.getFormattedMessage().contains(message))) {
final String formattedMessage = event.getFormattedMessage();

IThrowableProxy throwbleProxy = event.getThrowableProxy();
final String throwableString;
if (throwbleProxy != null) {
throwableString = ThrowableProxyUtil.asString(throwbleProxy);
} else {
throwableString = "";
}

if (this.excluded.stream()
.anyMatch(
message ->
formattedMessage.contains(message)
|| (!throwableString.equals("") && throwableString.contains(message)))) {
return FilterReply.DENY;
}
return FilterReply.ACCEPT;
Expand Down

0 comments on commit 98b4709

Please sign in to comment.