How to create a custom rolling file appender in log4j2 - customized file name

I would like to create log files using log4j2.

My requirement: I have to use the same log file name as below, even when rolling the file (as soon as it reaches 5 MB). Please note: I must 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 a new log file with different timestamps. For instance,

LogFileName_1834345_1.log  
LogFileName_1834345_2.log, etc

I think I need to use a custom copied file. But I do not know how to do this in log4j2.

Please help me.

+1
source share

All Articles