# Read the directory file name with logstash

**URL:** <https://discuss.elastic.co/t/read-the-directory-file-name-with-logstash/52283>\
**Category:** Logstash\
**Created:** [June 9, 2016, 6:28am UTC](https://discuss.elastic.co/t/read-the-directory-file-name-with-logstash/52283 "2016-06-09T06:28:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kennedy\_Kan1](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kennedy\_Kan1](https://discuss.elastic.co/u/Kennedy_Kan1)\
**Post date:** [June 9, 2016, 6:28am UTC](https://discuss.elastic.co/t/read-the-directory-file-name-with-logstash/52283/1 "2016-06-09T06:28:06Z")

</div>

I have logs file located in `C:/<project>/log/<wlsDomain>/<wlsServerName>/access.*.log`  
I have written a logstash conf file to read the logs but how can I also read the directory name **wlsDomain** in logstash as a new field?

---

<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:** [June 12, 2016, 11:19am UTC](https://discuss.elastic.co/t/read-the-directory-file-name-with-logstash/52283/2 "2016-06-12T11:19:28Z")

</div>

You'll get the full pathname of the input file in the `path` field. Use a grok filter to extract everything up to the last slash.

---

<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:53am UTC](https://discuss.elastic.co/t/read-the-directory-file-name-with-logstash/52283/3 "2017-07-06T04:53:30Z")

</div>


