# Logstash 6 - log rotation

**URL:** <https://discuss.elastic.co/t/logstash-6-log-rotation/109532>\
**Category:** Logstash\
**Created:** [November 29, 2017, 8:07am UTC](https://discuss.elastic.co/t/logstash-6-log-rotation/109532 "2017-11-29T08:07:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Duris](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@Martin\_Duris](https://discuss.elastic.co/u/Martin_Duris)\
**Post date:** [November 29, 2017, 8:07am UTC](https://discuss.elastic.co/t/logstash-6-log-rotation/109532/1 "2017-11-29T08:07:38Z")

</div>

Hi,  
i have upgraded to new version of Logstash 6, but i cannot setup logstash/log4j to keep only few log files (log files which are created by logstash, logstash installed from package dep package) (for example 7). My log4j:

```
status = error
name = LogstashPropertiesConfig

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}.log
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.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 7
appender.rolling.strategy.action.type = Delete
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %-.10000m%n
appender.rolling.MaxBackupIndex = 7

appender.json_rolling.type = RollingFile
appender.json_rolling.name = json_rolling
appender.json_rolling.fileName = ${sys:ls.logs}/logstash-${sys:ls.log.format}.log
appender.json_rolling.filePattern = ${sys:ls.logs}/logstash-${sys:ls.log.format}-%d{yyyy-MM-dd}.log
appender.json_rolling.policies.type = Policies
appender.json_rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.json_rolling.policies.time.interval = 1
appender.json_rolling.policies.time.modulate = true
appender.json_rolling.layout.type = JSONLayout
appender.json_rolling.layout.compact = true
appender.json_rolling.layout.eventEol = true
appender.json_rolling.MaxBackupIndex = 7

rootLogger.level = ${sys:ls.log.level}
rootLogger.appenderRef.rolling.ref = ${sys:ls.log.format}_rolling

```

Can you please help to configure it ? Or do i need to use logrotate ?

Thanks

---

<div class="post-metadata">

**Author:** ![JKhondhu](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@JKhondhu](https://discuss.elastic.co/u/JKhondhu)\
**Post date:** [November 30, 2017, 11:32pm UTC](https://discuss.elastic.co/t/logstash-6-log-rotation/109532/2 "2017-11-30T23:32:05Z")

</div>

Configure the _MaxBackupIndex_ to the number of days you want logging to be kept.

---

<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:** [December 28, 2017, 11:32pm UTC](https://discuss.elastic.co/t/logstash-6-log-rotation/109532/3 "2017-12-28T23:32:06Z")

</div>

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