簡體   English   中英

log4j 2 RollingFileAppender刪除日志內容

[英]log4j 2 RollingFileAppender deleting content of log

以下配置應該每天創建一個新的日志文件:

<configuration status="trace">
  <appenders>

    <RollingFile name="RollingFile" fileName="../logs/excepciones.log" filePattern="../logs/excepciones.log.%d{yyyy-MM-dd}">
     <PatternLayout>
       <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
     </PatternLayout>
     <Policies>
       <TimeBasedTriggeringPolicy interval="1" modulate="true" />
     </Policies>
   </RollingFile>
 </appenders>
 <loggers>

   <root level="error">
    <appender-ref ref="RollingFile"/>
   </root>
   <root level="info">
     <appender-ref ref="RollingFile"/>
   </root>
 </loggers>
</configuration>

我每天都會以excepciones.log-yyyy-MM-dd的形式獲取一個新文件,問題是該新文件僅包含插入到excepciones.log的最后一行,然后才將其滾動到excepciones.log-yyyy-MM-dd ,但我似乎無法弄清楚原因。 我想要的是將今天日志的全部內容在上午12:00復制到一個新文件中。

例如,昨天,我的日志內容為:

this is line 1
this is line 2
this is line 3

今天,該文件已重命名為`excepciones.log-2014-07-07,但其內容現在為:

this is line 1

您正在使用哪個版本的log4j2? 您的問題描述讓我想起了LOG4J2-531其固定在log4j2-RC1。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM