How to give dynamic file name in the appender in log4j.xml

后端 未结 5 1709
情深已故
情深已故 2020-11-28 06:16

I am using log4j to log information. I have used a log4j.xml file for creating log files. I have given the absolute path for each log file as a param

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 06:36

    It makes more sense to extend FileAppender with your own class, in which you override setOptions() method. Then in your log4j.properties you configure root to log to yourpackage.yourFileAppender, which is much cleaner.

提交回复
热议问题