Best practices for Java logging from multiple threads?

前端 未结 12 1250
星月不相逢
星月不相逢 2020-12-03 02:39

I want to have a diagnostic log that is produced by several tasks managing data. These tasks may be in multiple threads. Each task needs to write an element (possibly with s

12条回答
  •  庸人自扰
    2020-12-03 03:28

    Use a logging framework, such as Log4.

    and if you are not happy with the output you can write your own Appender, Filter, whatever to tweak it just write. So you could do even some caching to rearrange the entries, although I am not saying this is a good idea.

提交回复
热议问题