Log4j2 overwrites past day log file

后端 未结 4 1909
闹比i
闹比i 2021-01-15 12:01

I\'m using Log4j2 ver 2.3

log4j2.xml looks like:




    

        
相关标签:
4条回答
  • 2021-01-15 12:51

    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.

    0 讨论(0)
  • 2021-01-15 12:54

    try

    BasicConfigurator.resetConfiguration()
    

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

    0 讨论(0)
  • 2021-01-15 12:56

    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"
    
    0 讨论(0)
  • 2021-01-15 12:58

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

    0 讨论(0)
提交回复
热议问题