# How to rotate and compress logs using Logstash

**URL:** <https://discuss.elastic.co/t/how-to-rotate-and-compress-logs-using-logstash/58583>\
**Category:** Logstash\
**Created:** [August 22, 2016, 1:54pm UTC](https://discuss.elastic.co/t/how-to-rotate-and-compress-logs-using-logstash/58583 "2016-08-22T13:54:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daiyue](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@daiyue](https://discuss.elastic.co/u/daiyue)\
**Post date:** [August 22, 2016, 1:54pm UTC](https://discuss.elastic.co/t/how-to-rotate-and-compress-logs-using-logstash/58583/1 "2016-08-22T13:54:33Z")

</div>

Hi, I am wondering is it able to set log file rotation in terms of time in `logstash`, e.g. fetching and storing logs in the past 30 days, and then compressing the logs that exceed the time period and put them in some directories.

cheers

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 22, 2016, 2:10pm UTC](https://discuss.elastic.co/t/how-to-rotate-and-compress-logs-using-logstash/58583/2 "2016-08-22T14:10:07Z")

</div>

No, Logstash doesn't have any functionality for this.

---

<div class="post-metadata">

**Author:** ![daiyue](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@daiyue](https://discuss.elastic.co/u/daiyue)\
**Post date:** [August 22, 2016, 2:20pm UTC](https://discuss.elastic.co/t/how-to-rotate-and-compress-logs-using-logstash/58583/3 "2016-08-22T14:20:51Z")

</div>

Hi, what about `filebeat`, does it provide a similar function like simply specifying the time period for forwarding logs?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 22, 2016, 4:41pm UTC](https://discuss.elastic.co/t/how-to-rotate-and-compress-logs-using-logstash/58583/4 "2016-08-22T16:41:28Z")

</div>

I'm not sure exactly what you mean by

> specifying the time period for forwarding logs

but the answer is probably "no".

---

<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:** [July 6, 2017, 4:42am UTC](https://discuss.elastic.co/t/how-to-rotate-and-compress-logs-using-logstash/58583/5 "2017-07-06T04:42:14Z")

</div>

Closed on July 6, 2017, 4:42am UTC


