# Why logstash shut down when I use output to log.txt?

**URL:** <https://discuss.elastic.co/t/why-logstash-shut-down-when-i-use-output-to-log-txt/277837>\
**Category:** Logstash\
**Created:** [July 5, 2021, 1:09pm UTC](https://discuss.elastic.co/t/why-logstash-shut-down-when-i-use-output-to-log-txt/277837 "2021-07-05T13:09:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![111418](https://avatars.discourse-cdn.com/v4/letter/1/258eb7/32.png) [@111418](https://discuss.elastic.co/u/111418)\
**Post date:** [July 5, 2021, 1:09pm UTC](https://discuss.elastic.co/t/why-logstash-shut-down-when-i-use-output-to-log-txt/277837/1 "2021-07-05T13:09:53Z")

</div>

I have a log index "log\_index\_0701" and there is about 9000000 logs in this index.

I want to output this index log as a txt file but logstash always shut down when I output.

Here is my config

```auto
input{
   elasticsearch{
      hosts => ["localhost:9200"]
      index => "log_index_0701"
}
}

output{
    file{
     path=>"/etc/logstash/0701.txt"
     codec => line {format => "custom format : %{message}"}
}
}

```

And this is shut down message

```auto
 /usr/share/logstash/bin/logstash -f etc/logstash/conf.d/es_file.conf

[INFO] 2021-07-05 19:33:59.593 [Api Webserver] agent - Successfully started Logstash API endpoint {:port=>9601}
[INFO] 2021-07-05 19:33:59.916 [[main]>worker0] file - Opening file {:path=>"/etc/logstash/0701.txt"}
[INFO] 2021-07-05 19:49:12.387 [[main]-pipeline-manager] javapipeline - Pipeline terminated {"pipeline.id"=>"main"}
[INFO] 2021-07-05 19:49:12.561 [LogStash::Runner] runner - Logstash shut down.

```

How can I solve this problem?  
Thank you

---

<div class="post-metadata">

**Author:** ![AquaX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquax/32/92006_2.png) [@AquaX](https://discuss.elastic.co/u/AquaX)\
**Post date:** [July 14, 2021, 4:18pm UTC](https://discuss.elastic.co/t/why-logstash-shut-down-when-i-use-output-to-log-txt/277837/2 "2021-07-14T16:18:06Z")

</div>

You need to supply a query to elasticsearch in your input otherwise it will just run:

```auto
'{ "sort": ["_doc"] }'

```

> **[Elasticsearch input plugin | Logstash Reference \[7.13\] | Elastic](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-elasticsearch.html#plugins-inputs-elasticsearch-query)**

Logstash shuts down because you do not have a set schedule and as far as it is concerned it is done doing what it needs to do.

---

<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:** [August 11, 2021, 4:18pm UTC](https://discuss.elastic.co/t/why-logstash-shut-down-when-i-use-output-to-log-txt/277837/3 "2021-08-11T16:18:09Z")

</div>

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