简体   繁体   中英

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!

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, eg by throwing a specific exception (LongTermFailure) in the Open or Half-Open state of the Breaker and treating that differently at your logging place.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM