dynamically creating & destroying logging appenders

前端 未结 2 419
猫巷女王i
猫巷女王i 2021-01-19 04:20

I have a legacy PSVM application which I\'d like to redirect its logging output to unique files per execution. So, if I invoke it at 10:00, then have it redirect it\'s outp

2条回答
  •  Happy的楠姐
    2021-01-19 04:56

    It is not possible, at least not easy to do in log4j. However, if you look at SiftingAppender shipping with logback (log4j's successor), it is designed to handle the creation of appenders on runtime criteria as well as their removal when no longer needed.

    If you application needs to create just one log file per application launch, you could simply name your log file based on a timestamp. Shout on the logback-user mailing list if you need further assistance.

提交回复
热议问题