# How do I rotate the output log files of logstash

**URL:** <https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108>\
**Category:** Logstash\
**Created:** [September 11, 2015, 8:54am UTC](https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108 "2015-09-11T08:54:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![achakrab22](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@achakrab22](https://discuss.elastic.co/u/achakrab22)\
**Post date:** [September 11, 2015, 8:54am UTC](https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108/1 "2015-09-11T08:54:37Z")

</div>

Hi I am trying to log all the logstash output including Errors /Info. What is the best recommended way? Also I want to rotate the log file. I see there is an output-\> file command supported in config. but the option max\_size is not yet supported. Also there is a --log command line arg. Can someone recommend a good way for logging all the messages logstash spits out. Also is there a performance consideration if logstash spits out all the outputs to log files? Many Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 11, 2015, 9:07am UTC](https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108/2 "2015-09-11T09:07:28Z")

</div>

Output to a file is very inefficient as it's a lot of IO.  
Where else are you storing the data?

---

<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:** [September 11, 2015, 9:08am UTC](https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108/3 "2015-09-11T09:08:00Z")

</div>

Are you talking about Logstash's own logs or messages processed by Logstash?

---

<div class="post-metadata">

**Author:** ![achakrab22](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@achakrab22](https://discuss.elastic.co/u/achakrab22)\
**Post date:** [September 11, 2015, 9:32am UTC](https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108/4 "2015-09-11T09:32:35Z")

</div>

This is the logstash output (logs printed by logstash) both Error/Info and the messages it sends to output.

---

<div class="post-metadata">

**Author:** ![achakrab22](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@achakrab22](https://discuss.elastic.co/u/achakrab22)\
**Post date:** [September 11, 2015, 9:34am UTC](https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108/5 "2015-09-11T09:34:15Z")

</div>

Answering Mark I am sending the data to Elastic and also want to log it somewhere what I have sent , are you saying instead of file plugin I should redirect stdout/error to a file or should try to avoid the whole thing ?

---

<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:** [September 11, 2015, 10:56am UTC](https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108/6 "2015-09-11T10:56:42Z")

</div>

> Answering Mark I am sending the data to Elastic and also want to log it somewhere what I have sent , are you saying instead of file plugin I should redirect stdout/error to a file or should try to avoid the whole thing ?

If you care about I/O load then you should avoid it. Not sure why you feel the need to store everything locally when you're already pushing it into Elasticsearch.

Logstash's Debian and RPM packages include a [logrotate configuration file](https://github.com/elastic/logstash/blob/v1.5.4/pkg/logrotate.conf) that causes /var/log/logstash/logstash.log to get rotated daily with a week's worth of logs kept around.

---

<div class="post-metadata">

**Author:** ![wolfghost](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfghost/32/15500_2.png) [@wolfghost](https://discuss.elastic.co/u/wolfghost)\
**Post date:** [February 14, 2017, 11:21am UTC](https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108/7 "2017-02-14T11:21:56Z")

</div>

Thanks  
i want to read logs form mongodb so how can i do that??

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 14, 2017, 11:25am UTC](https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108/8 "2017-02-14T11:25:04Z")

</div>

Please start your own thread.

---

<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:28am UTC](https://discuss.elastic.co/t/how-do-i-rotate-the-output-log-files-of-logstash/29108/9 "2017-07-06T04:28:38Z")

</div>


