# Logstash rolling log file

**URL:** <https://discuss.elastic.co/t/logstash-rolling-log-file/152957>\
**Category:** Logstash\
**Created:** [October 18, 2018, 8:09am UTC](https://discuss.elastic.co/t/logstash-rolling-log-file/152957 "2018-10-18T08:09:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![manikandanid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manikandanid/32/91013_2.png) [@manikandanid](https://discuss.elastic.co/u/manikandanid)\
**Post date:** [October 18, 2018, 8:09am UTC](https://discuss.elastic.co/t/logstash-rolling-log-file/152957/1 "2018-10-18T08:09:33Z")

</div>

Hi,

I am new to ES and in the process of learning it. Currently, I need to roll out the log file on size based (100MB each), not more than 2 files to be created in a day and need to preserve the log file only for 4 days. Following is the configuration i have mentioned in log4j2.properties but it's not working.

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 = 100MB  
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 = IfLastModified  
appender.rolling.strategy.action.condition.age = 4D  
appender.rolling.strategy.action.PathConditions.type = IfFileName  
appender.rolling.strategy.action.PathConditions.glob = logstash-${sys:ls.log.format}-\*

Can anyone help me in this.

---

<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:** [November 15, 2018, 8:24am UTC](https://discuss.elastic.co/t/logstash-rolling-log-file/152957/2 "2018-11-15T08:24:31Z")

</div>

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