# File output to multiple files

**URL:** <https://discuss.elastic.co/t/file-output-to-multiple-files/171721>\
**Category:** Logstash\
**Created:** [March 11, 2019, 10:03am UTC](https://discuss.elastic.co/t/file-output-to-multiple-files/171721 "2019-03-11T10:03:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![romariol](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@romariol](https://discuss.elastic.co/u/romariol)\
**Post date:** [March 11, 2019, 10:03am UTC](https://discuss.elastic.co/t/file-output-to-multiple-files/171721/1 "2019-03-11T10:03:48Z")

</div>

I have a Logstash conf where I split an incoming XML into multiple events. I would like to write a file per event. However, the file output writes all the events to a single file (so an event per line). Is there a way to achieve this?

```
filter {

xml{
   store_xml => "false"
   source => "message"
remove_namespaces => true
xpath => 
 [
"/root/Envelope", "Envelopes"         
   ]
  }

mutate {
    remove_field => ["message"]
  }

 split{
  field => "Envelopes"
 }
}

output {
file {
path => "/install/logstash/output-CL102-%{+yyyyMMddHHmmss}.xml"
}
}

```

Thanks

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [March 12, 2019, 1:11am UTC](https://discuss.elastic.co/t/file-output-to-multiple-files/171721/2 "2019-03-12T01:11:15Z")

</div>

If the sprintf format string provided to the file output plugin's `path` directive creates unique value per event, then you will effectively write exactly one event per file.

One way to create a unique field on an event is with the [Fingerprint Filter Plugin](https://www.elastic.co/guide/en/logstash/current/plugins-filters-fingerprint.html).

---

<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:** [April 9, 2019, 1:11am UTC](https://discuss.elastic.co/t/file-output-to-multiple-files/171721/3 "2019-04-09T01:11:18Z")

</div>

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