# Filebeat locks the file rotation for log4j causing the files to grow enormously

**URL:** <https://discuss.elastic.co/t/filebeat-locks-the-file-rotation-for-log4j-causing-the-files-to-grow-enormously/164428>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [January 16, 2019, 9:38am UTC](https://discuss.elastic.co/t/filebeat-locks-the-file-rotation-for-log4j-causing-the-files-to-grow-enormously/164428 "2019-01-16T09:38:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CaptainAye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/captainaye/32/37271_2.png) [@CaptainAye](https://discuss.elastic.co/u/CaptainAye)\
**Post date:** [January 16, 2019, 9:38am UTC](https://discuss.elastic.co/t/filebeat-locks-the-file-rotation-for-log4j-causing-the-files-to-grow-enormously/164428/1 "2019-01-16T09:38:37Z")

</div>

Hello,

Sometimes the logs in my application are not rolled as they should be and they grow in size (the limit is 10mb)  
I receive an exception if Filebeat logs:

```auto
Err: error setting up harvester: Harvester setup failed. Unexpected file opening error: Failed opening C:\application\logs\app.log.5: Error creating file 'C:\application\logs\app.log.5': Access is denied.

```

```auto
input state for C:\application\logs\app.log.2 was not removed: CreateFile C:\application\logs\app.log.2: Access is denied.

```

**Then, Filebeat seems to keep a lock on the files on which the exception occured and they cannot be deleted/moved, so that logger keeps writing to the currently active file, which grows.**

**Are there tuning options or something to handle such situations?**

I would like to make sure that if the log file is rotated before filebeat finishes reading it, I will not lose any data.

I use filebeat 6.4.2 with following input configuration :

```auto
    - type: log
      enabled: true
      close_renamed: true
      paths:
       - C:\application\logs\app.log*
      multiline:
        pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}'
        negate: true
        match: after

```

I have the application which uses log4j for logging and it should rotate each log file whenever it reaches 10mb.

Best regards,

---

<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 13, 2019, 9:38am UTC](https://discuss.elastic.co/t/filebeat-locks-the-file-rotation-for-log4j-causing-the-files-to-grow-enormously/164428/2 "2019-02-13T09:38:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
