# Filebeat read log4j2 rotated log file again

**URL:** <https://discuss.elastic.co/t/filebeat-read-log4j2-rotated-log-file-again/118565>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [February 6, 2018, 7:00am UTC](https://discuss.elastic.co/t/filebeat-read-log4j2-rotated-log-file-again/118565 "2018-02-06T07:00:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Denshou](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Denshou](https://discuss.elastic.co/u/Denshou)\
**Post date:** [February 6, 2018, 7:00am UTC](https://discuss.elastic.co/t/filebeat-read-log4j2-rotated-log-file-again/118565/1 "2018-02-06T07:00:45Z")

</div>

Hi, I am using filebeat 6.1.3 in windows to read log files from log4j2 to logstash.  
When the logfile ratated from xxx.log -\> xxx.log.1  
logstash received the lines in file xxx.log.1 again  
so all the log is read twice.

Can you please tell me if anything wrong in my configs?

* * *

log4j2.xml:  
\<RollingFile name="file2"  
append="true"  
fileName="C:/xxx/log/log4j2-test.log"  
filePattern="C:/xxx/log/log4j2-test.log.%i"\>  
\<PatternLayout pattern="${ptn}" /\>  
\<Policies\>  
\<SizeBasedTriggeringPolicy size="10 KB" /\>  
\</Policies&lgt;  
\<DefaultRolloverStrategy fileIndex="min" min="1" max="5" /\>  
\</RollingFile\>

* * *

filebeat.yml:

- type: log  
paths:

output.logstash:  
hosts: ["localhost:5044"]

* * *

logstash conf:

beats {  
port =\> 5044  
}

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [February 6, 2018, 11:09am UTC](https://discuss.elastic.co/t/filebeat-read-log4j2-rotated-log-file-again/118565/2 "2018-02-06T11:09:40Z")

</div>

Hi @Denshou,

By adding a `*` at the end of `C:/xxx/log/log4j2-test.log` you are instructing Filebeat to read `.1` file too, so it takes it as a new file and sends everything. Perhaps you wan to drop the `*`?

Best regards

---

<div class="post-metadata">

**Author:** ![Denshou](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Denshou](https://discuss.elastic.co/u/Denshou)\
**Post date:** [February 7, 2018, 12:36am UTC](https://discuss.elastic.co/t/filebeat-read-log4j2-rotated-log-file-again/118565/3 "2018-02-07T00:36:38Z")

</div>

Hi, exekias, thanks very much!  
I tested the setting but found that when the log file rotated  
in the interval of the file beat, the rotated logs is lost.  
eg:  
log1  
log2  
log3 -\> file beat output to logstash here with 1,2,3  
log4  
log5 -\> here, .log ratated to .log.1  
the following log is output to new .log file  
log6  
log7 -\> file beat output to logstash here with 6,7  
and the log 4,5 is missed

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 27, 2018, 7:01am UTC](https://discuss.elastic.co/t/filebeat-read-log4j2-rotated-log-file-again/118565/4 "2018-02-27T07:01:04Z")

</div>

This topic was automatically closed after 21 days. New replies are no longer allowed.
