# Logstash FileOutput Custom Name

**URL:** <https://discuss.elastic.co/t/logstash-fileoutput-custom-name/251838>\
**Category:** Logstash\
**Created:** [October 13, 2020, 4:18am UTC](https://discuss.elastic.co/t/logstash-fileoutput-custom-name/251838 "2020-10-13T04:18:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mastersmit](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@mastersmit](https://discuss.elastic.co/u/mastersmit)\
**Post date:** [October 13, 2020, 4:18am UTC](https://discuss.elastic.co/t/logstash-fileoutput-custom-name/251838/1 "2020-10-13T04:18:00Z")

</div>

I have a requirement where the file name (in the output) in a specific way.

After 11.30pm, It need to take next day date.

For example, today is 13th Oct 2020, the file name is `ouput_13102020.log` but then once it passes 11.30pm then the output should be `output_14102020.log` Because i need file data from 11.30.001 to next day 11.30.000

I could build file name in the ruby script and set a `event.set('filename', value)` but i am wondering if there is a better way to do it.

Here is code snippet generating the logic:

```auto
require 'date'

time = Time.now

if time.hour == 4 && time.min > 30
    time = DateTime.now.next_day(1).to_time
end

puts "logstash_output_"+time.strftime("%d%m%Y") 

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [October 13, 2020, 3:58pm UTC](https://discuss.elastic.co/t/logstash-fileoutput-custom-name/251838/2 "2020-10-13T15:58:41Z")

</div>

> [@mastersmit](#):
>
> I could build file name in the ruby script and set a `event.set('filename', value)`

That is the approach I would use.

---

<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:** [November 10, 2020, 3:58pm UTC](https://discuss.elastic.co/t/logstash-fileoutput-custom-name/251838/3 "2020-11-10T15:58:48Z")

</div>

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