问题
Does any logging library contain any means to limit logging message frequency?
I mean suppose I have a waiting loop and it logs "Nothing done". How to make next "Nothing done" message would logged only after say 1 second?
I know I can program it myself.
回答1:
You have to manage this in your code, or you need to write a custom appender (this depends on the logging library you are using)
回答2:
Most logging libraries support filters to limit logging frequency.
- See this answer on SLF4J or Log4J.
- See this answer on java.util.logging.
来源:https://stackoverflow.com/questions/10212644/how-to-limit-logging-frequency