# Logstash output filename timezone problem

**URL:** <https://discuss.elastic.co/t/logstash-output-filename-timezone-problem/69894>\
**Category:** Logstash\
**Created:** [December 23, 2016, 9:47am UTC](https://discuss.elastic.co/t/logstash-output-filename-timezone-problem/69894 "2016-12-23T09:47:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![for\_logstash](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@for\_logstash](https://discuss.elastic.co/u/for_logstash)\
**Post date:** [December 23, 2016, 9:47am UTC](https://discuss.elastic.co/t/logstash-output-filename-timezone-problem/69894/1 "2016-12-23T09:47:46Z")

</div>

Hi

I want to output the file using current time just like the config below.  
output {  
file {  
path =\>"/home/test/%{+YYYYMMdd}/nginx\_%{+YYYYMMdd\_HH}.log"  
}  
}

the filename generated use the UTC timezone time, But I want to ouput the filename with my local time zone(Asia/Beijing)  
e.g my local current time is "2016-12-23 17:44"

run the config file above, the filename is "nginx\_20161223\_09.log"

how can I get the filename using my timezone,just like this "nginx\_20161223\_17.log"???

Thanks!!!

---

<div class="post-metadata">

**Author:** ![for\_logstash](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@for\_logstash](https://discuss.elastic.co/u/for_logstash)\
**Post date:** [December 26, 2016, 2:31am UTC](https://discuss.elastic.co/t/logstash-output-filename-timezone-problem/69894/2 "2016-12-26T02:31:46Z")

</div>

I am new to logstash, who can help me?

---

<div class="post-metadata">

**Author:** ![danielwalker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielwalker/32/14396_2.png) [@danielwalker](https://discuss.elastic.co/u/danielwalker)\
**Post date:** [December 28, 2016, 5:46am UTC](https://discuss.elastic.co/t/logstash-output-filename-timezone-problem/69894/3 "2016-12-28T05:46:38Z")

</div>

ha, we are in the same situation here.

---

<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 28, 2016, 8:47pm UTC](https://discuss.elastic.co/t/logstash-output-filename-timezone-problem/69894/4 "2016-12-28T20:47:03Z")

</div>

UTC is used and this isn't configurable. What you can do (although I think it's a mistake) is to use a ruby filter to create a `@metadata` field containing the date you want and then reference _that_ field in the file output's path configuration.

---

<div class="post-metadata">

**Author:** ![danielwalker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielwalker/32/14396_2.png) [@danielwalker](https://discuss.elastic.co/u/danielwalker)\
**Post date:** [January 4, 2017, 10:05am UTC](https://discuss.elastic.co/t/logstash-output-filename-timezone-problem/69894/5 "2017-01-04T10:05:34Z")

</div>

Sorry, but could you please show us the code snippet?

---

<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:** [January 4, 2017, 10:23am UTC](https://discuss.elastic.co/t/logstash-output-filename-timezone-problem/69894/6 "2017-01-04T10:23:33Z")

</div>

I'm afraid I don't have a code snippet handy. What part are you having trouble with?

---

<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:** [February 1, 2017, 10:24am UTC](https://discuss.elastic.co/t/logstash-output-filename-timezone-problem/69894/7 "2017-02-01T10:24:03Z")

</div>

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