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

前端 未结 4 1424
天命终不由人
天命终不由人 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:41

    The file appenders have no option to lazily create the log files - the setFile method automatically creates the file if it doesn't already exist: ostream = new FileOutputStream(fileName, append);

    You'll have to extend the appender and overwrite the file initialisation code yourself to get the behaviour you're after.

提交回复
热议问题