Creating log4j log file for each run with Date and timestamp

后端 未结 2 1174
粉色の甜心
粉色の甜心 2021-01-12 16:37

All, it seems like this question is posted multiple times but still i haven\'t got proper solution for my problem. I referred this and this but its not working.

As p

2条回答
  •  孤独总比滥情好
    2021-01-12 16:39

    One simple way to execute this is: 1.) setting a property in before hooks for the current timestamp.

        SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy-hh-mm-ss");
        System.setProperty("current.date.time", dateFormat.format(new Date()));
    

    2.) Use this env variable property to create your logger file name log4j.appender.file.File=${user.dir}/logs/Logger_${current.date.time}.logs

提交回复
热议问题