From 8d5a6876a31ecad641b25636d85e8b3099dff35e Mon Sep 17 00:00:00 2001 From: Masterchen09 <13187726+Masterchen09@users.noreply.github.com> Date: Sun, 28 Apr 2024 17:13:15 +0200 Subject: [PATCH 1/4] fix: also check exceptions/stack trace when filtering log messages --- .../metadata/utils/log/LogMessageFilter.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java b/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java index 67f0ae4c77eaf..15cb3adfcb45e 100644 --- a/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java +++ b/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java @@ -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; @@ -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; From a689fdc59516bb225a6e942efe93cc6fac3e1b24 Mon Sep 17 00:00:00 2001 From: John Joyce Date: Fri, 28 Jun 2024 14:52:54 -0700 Subject: [PATCH 2/4] Update LogMessageFilter.java --- .../com/linkedin/metadata/utils/log/LogMessageFilter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java b/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java index 15cb3adfcb45e..a386ee69bab7e 100644 --- a/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java +++ b/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java @@ -25,10 +25,10 @@ public FilterReply decide(ILoggingEvent event) { final String formattedMessage = event.getFormattedMessage(); - IThrowableProxy throwbleProxy = event.getThrowableProxy(); + IThrowableProxy throwableProxy = event.getThrowableProxy(); final String throwableString; - if (throwbleProxy != null) { - throwableString = ThrowableProxyUtil.asString(throwbleProxy); + if (throwableProxy != null) { + throwableString = ThrowableProxyUtil.asString(throwableProxy); } else { throwableString = ""; } From 769d952f8be5182f06f4452a221a442b12fb0c5e Mon Sep 17 00:00:00 2001 From: John Joyce Date: Fri, 28 Jun 2024 14:53:49 -0700 Subject: [PATCH 3/4] Update LogMessageFilter.java --- .../linkedin/metadata/utils/log/LogMessageFilter.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java b/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java index a386ee69bab7e..a48b529007757 100644 --- a/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java +++ b/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java @@ -24,20 +24,17 @@ public FilterReply decide(ILoggingEvent event) { } final String formattedMessage = event.getFormattedMessage(); - - IThrowableProxy throwableProxy = event.getThrowableProxy(); - final String throwableString; + final IThrowableProxy throwableProxy = event.getThrowableProxy(); + String throwableString = null; if (throwableProxy != null) { throwableString = ThrowableProxyUtil.asString(throwableProxy); - } else { - throwableString = ""; } if (this.excluded.stream() .anyMatch( message -> formattedMessage.contains(message) - || (!throwableString.equals("") && throwableString.contains(message)))) { + || (throwableString != null && throwableString.contains(message)))) { return FilterReply.DENY; } return FilterReply.ACCEPT; From 858df9df5c2d1c6c383cfc3017ed13998b78e944 Mon Sep 17 00:00:00 2001 From: Masterchen09 <13187726+Masterchen09@users.noreply.github.com> Date: Sat, 29 Jun 2024 17:37:44 +0200 Subject: [PATCH 4/4] Update LogMessageFilter.java --- .../com/linkedin/metadata/utils/log/LogMessageFilter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java b/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java index a48b529007757..3750c0ae0bc4a 100644 --- a/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java +++ b/metadata-utils/src/main/java/com/linkedin/metadata/utils/log/LogMessageFilter.java @@ -25,9 +25,12 @@ public FilterReply decide(ILoggingEvent event) { final String formattedMessage = event.getFormattedMessage(); final IThrowableProxy throwableProxy = event.getThrowableProxy(); - String throwableString = null; + + String throwableString; if (throwableProxy != null) { throwableString = ThrowableProxyUtil.asString(throwableProxy); + } else { + throwableString = null; } if (this.excluded.stream()