How to limit logging frequency?

狂风中的少年 提交于 2019-12-11 09:39:15

问题


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.

  1. See this answer on SLF4J or Log4J.
  2. See this answer on java.util.logging.


来源:https://stackoverflow.com/questions/10212644/how-to-limit-logging-frequency

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!