Log4j2 overwrites past day log file

孤者浪人 提交于 2019-12-01 14:09:57

Log4j 2.3 is somewhat old, being released on 2015-05-09, almost 3 years old. So try using a updated version; version 2.11.0 is the latest as of now which was released on 2018-03-11.

Update: To continue using Log4j 2.3, you can compromise your requirements. One of the options could be using static value for fileName attribute. E.g. .../catalina.log, .../catalina.current.log, etc.

try

BasicConfigurator.resetConfiguration()

in the method that uses logger after BasicConfigurator.configure()

Try adding an auto-increment variable to your file pattern (%i). This worked fine for me.

filePattern="${sys:catalina.base}/logs/catalina.%d{yyyy-MM-dd}.%i.log"

mention in time based TimeBasedTriggeringPolicy time interval as 1 it will rollover file on daylly basis

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