-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/java/de/tum/cit/aet/artemis/core/config/StompErrorLogFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package de.tum.cit.aet.artemis.core.config; | ||
|
||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
import ch.qos.logback.core.filter.Filter; | ||
import ch.qos.logback.core.spi.FilterReply; | ||
|
||
/** | ||
* A custom Logback filter to suppress specific log messages from the | ||
* StompBrokerRelayMessageHandler in a Spring Boot application. | ||
* | ||
* <p> | ||
* This filter identifies log messages containing the error: | ||
* "Did not receive data from ... within the 60000ms connection TTL. The connection will now be closed." | ||
* and suppresses them while allowing other log messages to pass through. | ||
* | ||
* <p> | ||
* The purpose of this filter is to reduce noise in the logs by eliminating | ||
* repetitive or irrelevant error messages caused by client disconnections. | ||
*/ | ||
public class StompErrorLogFilter extends Filter<ILoggingEvent> { | ||
|
||
/** | ||
* Decides whether a log message should be suppressed or passed through. | ||
* | ||
* <p> | ||
* This method checks if the log message originates from the | ||
* StompBrokerRelayMessageHandler logger and contains the specific error message | ||
* about the 60000ms connection TTL timeout. If both conditions are met, | ||
* the log message is suppressed (denied). All other log messages are allowed. | ||
* | ||
* @param event the logging event containing the log message and metadata | ||
* @return {@code FilterReply.DENY} if the message matches the specific error to suppress, | ||
* otherwise {@code FilterReply.NEUTRAL} to allow the message through. | ||
*/ | ||
@Override | ||
public FilterReply decide(ILoggingEvent event) { | ||
String loggerName = event.getLoggerName(); | ||
String message = event.getFormattedMessage(); | ||
|
||
// Check if the logger and message match the specific error to suppress | ||
if ("org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler".equals(loggerName) && message.contains("Did not receive data from") | ||
&& message.contains("connection TTL. The connection will now be closed.")) { | ||
return FilterReply.DENY; // Suppress this specific log message | ||
} | ||
|
||
return FilterReply.NEUTRAL; // Allow other messages | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters