How do I make log4j create log files on demand only?

前端 未结 4 1425
天命终不由人
天命终不由人 2020-12-16 02:12

We have a modular application where modules have their own log4j logs (i.e. communication log and error log). The appenders and categories for these are all configured in th

4条回答
  •  轮回少年
    2020-12-16 02:54

    I had the same problem, so I have extended the standard FileAppender class and I have created a new LazyFileAppender that is a FileAppender that lazily initialize the log file(creates it only when the first write operation happens).

    The LazyFileAppender and some other additions to the standard log4j library can be found into a simple library that I have created : log4j-additions .

    You can look at the source to develop your own extension or you can use it as is ...

提交回复
热议问题