# Rolling Logs in Logstash?

**URL:** <https://discuss.elastic.co/t/rolling-logs-in-logstash/37268>\
**Category:** Logstash\
**Created:** [December 15, 2015, 5:19pm UTC](https://discuss.elastic.co/t/rolling-logs-in-logstash/37268 "2015-12-15T17:19:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![parthu](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@parthu](https://discuss.elastic.co/u/parthu)\
**Post date:** [December 15, 2015, 5:19pm UTC](https://discuss.elastic.co/t/rolling-logs-in-logstash/37268/1 "2015-12-15T17:19:55Z")

</div>

Every time there's an event in Logstash, I ensure that it's logged in a log file. But the problem is that .. the log file keeps growing every day. I need to segregrate logs by the day so I could delete old logs as per my convenience. So, my question is .. Can we have rolling logs for Logstash?

---

<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:** [December 15, 2015, 6:26pm UTC](https://discuss.elastic.co/t/rolling-logs-in-logstash/37268/2 "2015-12-15T18:26:21Z")

</div>

How are you logging the messages, via a file output or a stdout output? In the latter case I think external rotation already works (i.e. use logrotate or a similar tool) but the file output doesn't support external renames. See the issue below.

Keep in mind that the plugin's `path` option supports [sprintf formatted strings](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#sprintf) so you could use e.g. `/path/to/logfile.%{+YYYY.MM.DD}.log` as the output file's path to have it write events to files named after the `@timestamp` field.

> <https://github.com/logstash-plugins/logstash-output-file/issues/10>

---

<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, 5:18am UTC](https://discuss.elastic.co/t/rolling-logs-in-logstash/37268/3 "2017-07-06T05:18:20Z")

</div>


