How to create Custom Rolling File appender in log4

2019-08-02 18:27发布

问题:

I would like to create the log files using log4j2.

My requirement: I have to use the same log file name like below even when rolling the file (once it reaches 5MB). Please note, i have to use the same timestamp (110923) until the server runs continuously.

LogFileName_110923_1.log  
LogFileName_110923_2.log, etc  

When the server restarts I will have to create new log file with different timestamps. Like,

LogFileName_1834345_1.log  
LogFileName_1834345_2.log, etc

I think i have to use custom rolling file appender. But I don't know how to achieve it in log4j2.

Please assist me.