How to create Custom Rolling File appender in log4j2 - customized file name

落花浮王杯 提交于 2020-01-05 08:02:07

问题


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.

来源:https://stackoverflow.com/questions/41669056/how-to-create-custom-rolling-file-appender-in-log4j2-customized-file-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!