# Logstash + elasticsearch log rotation

**URL:** <https://discuss.elastic.co/t/logstash-elasticsearch-log-rotation/165022>\
**Category:** Logstash\
**Created:** [January 21, 2019, 9:56am UTC](https://discuss.elastic.co/t/logstash-elasticsearch-log-rotation/165022 "2019-01-21T09:56:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HugoSousa](https://avatars.discourse-cdn.com/v4/letter/h/90db22/32.png) [@HugoSousa](https://discuss.elastic.co/u/HugoSousa)\
**Post date:** [January 21, 2019, 9:56am UTC](https://discuss.elastic.co/t/logstash-elasticsearch-log-rotation/165022/1 "2019-01-21T09:56:33Z")

</div>

Hi,

Can someone help me with the configuration of logrotation in logstash and in elasticsearch? I am using v5 of elasticsearch.

My goal is to have a similar log rotation, like I have configured in filebeat (which is below)

-----------Filebeat cfg file-----------  
# The name of the files where the logs are written to.  
name: mybeat

```
# Configure log file size limit. If limit is reached, log file will be
# automatically rotated
rotateeverybytes: 10485760 # = 10MB

# Number of rotated log files to keep. Oldest files will be deleted first.
keepfiles: 7

```

* * *

my log4j2.properties file which I have configured with the following settings, but they dont see to be applied...

##### 

appender.rolling.type = RollingFile  
appender.rolling.name = plain\_rolling  
appender.rolling.fileName = {sys:ls.logs}/logstash-{sys:ls.log.format}.log  
appender.rolling.filePattern = {sys:ls.logs}/logstash-{sys:ls.log.format}-%d{yyyy-MM-dd}-%i.log.gz  
appender.rolling.policies.type = Policies  
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy  
appender.rolling.policies.time.interval = 1  
appender.rolling.policies.time.modulate = true  
appender.rolling.layout.type = PatternLayout  
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %-.10000m%n  
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy  
appender.rolling.policies.size.size = 10MB  
appender.rolling.strategy.type = DefaultRolloverStrategy  
appender.rolling.strategy.max = 2  
appender.rolling.strategy.action.type = Delete  
appender.rolling.strategy.action.basepath = {sys:ls.logs} appender.rolling.strategy.action.condition.type = IfFileName appender.rolling.strategy.action.condition.glob = logstash-{sys:ls.log.format}-\*  
appender.rolling.strategy.action.ifAny.type = IfAny  
appender.rolling.strategy.action.ifAny.ifLastModified.type = IfLastModified  
appender.rolling.strategy.action.ifAny.ifLastModified.age = 3D  
appender.rolling.strategy.action.ifAny.ifAccumulatedFileSize.type = IfAccumulatedFileSize  
appender.rolling.strategy.action.ifAny.ifAccumulatedFileSize.exceeds = 100MB

##### 

Thanks in advance.  
Hugo

---

<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 18, 2019, 9:58am UTC](https://discuss.elastic.co/t/logstash-elasticsearch-log-rotation/165022/2 "2019-02-18T09:58:41Z")

</div>

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