Mr. B.
Mr. B.

Reputation: 8697

Android/Java: how to avoid repetitive errors logs?

I've a service that runs every 5 seconds and fires 10-15 HTTP requests each time.

If the requests fail (timeout), I throw up to 15 errors every 5 seconds. That bloats the log files.

I'd like to log repetitive errors only every 30 minutes, even if the service runs every 5 seconds.

Any idea?

Thank you in advance!

Upvotes: 0

Views: 80

Answers (1)

Ralf Kleberhoff
Ralf Kleberhoff

Reputation: 7290

Have a look at the Circuit Breaker Pattern for detecting long-term failures.

You still need a way to not log the errors during the long-term failure, e.g. by throwing a specific exception (LongTermFailure) in the Open or Half-Open state of the Breaker and treating that differently at your logging place.

Upvotes: 1

Related Questions