/

Duplicate Suppression

Duplicate suppression prevents log flooding by suppressing repeated identical messages within a configurable time window.

Configure Duplicate Suppression

Set the suppression window in milliseconds:

Java
// Suppress duplicates within 5 seconds
Log.setDuplicateSuppressionWindow(5000L);

How It Works

When duplicate suppression is enabled, identical messages within the time window are suppressed:

Java
Log.setDuplicateSuppressionWindow(5000L);  // 5 second window

// First call - logged
Log.error("Connection failed");

// Within 5 seconds - suppressed
Log.error("Connection failed");
Log.error("Connection failed");

// After 5 seconds - logged again
Log.error("Connection failed");

Configuration Examples

Development

Java
// Shorter window for development
Log.setDuplicateSuppressionWindow(1000L);  // 1 second

Production

Java
// Longer window for production
Log.setDuplicateSuppressionWindow(10000L);  // 10 seconds

High-Volume Applications

Java
// Aggressive suppression
Log.setDuplicateSuppressionWindow(60000L);  // 1 minute

Use Cases

Preventing Error Floods

Java
Log.setDuplicateSuppressionWindow(5000L);

// In a retry loop, only the first error is logged per window
for (int i = 0; i < 100; i++) {
    try {
        connectToService();
        break;
    } catch (Exception e) {
        Log.error("Service connection failed");  // Only logged once per 5 seconds
    }
}

Best Practices

Duplicate Suppression Best Practices

  • Use shorter windows (1-5 seconds) in development
  • Use longer windows (10-60 seconds) in production
  • Enable for error-prone operations like retries and polling
  • Monitor suppressed count to identify underlying issues

Next Steps

Previous
Correlation IDs