# Gc logs written to multiple locations

**URL:** <https://discuss.elastic.co/t/gc-logs-written-to-multiple-locations/360542>\
**Category:** Elasticsearch\
**Created:** [May 30, 2024, 8:47am UTC](https://discuss.elastic.co/t/gc-logs-written-to-multiple-locations/360542 "2024-05-30T08:47:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kg.sterneberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kg.sterneberg/32/134928_2.png) [@kg.sterneberg](https://discuss.elastic.co/u/kg.sterneberg)\
**Post date:** [May 30, 2024, 8:47am UTC](https://discuss.elastic.co/t/gc-logs-written-to-multiple-locations/360542/1 "2024-05-30T08:47:35Z")

</div>

Just upgraded to Elasticsearch 8. and gc logs are now written to two locations. As specified in `<ES_PATH_CONF>\jvm.options.d\jvm.options`, but also to default location `elasticsearch-8.13.4\logs\`. In the location specified i jvm.options, only the configured number of gc logs are kept. In `elasticsearch-8.13.4\logs\`, the gc logs does not seem to be purged.

I have tested to add the file gc.options to `<ES_PATH_CONF>\jvm.options.d\jvm.options`. Content:

```auto
# Turn off all previous logging configuratons
-Xlog:disable

# Default settings from JEP 158, but with `utctime` instead of `uptime` to match the next line
-Xlog:all=warning:stderr:utctime,level,tags

# Enable GC logging to a custom location with a variety of options
-Xlog:gc*,gc+age=trace,safepoint:file=C:\Elasticsearch-8\logs-gc\gc9.log:utctime,pid,tags:filecount=4,filesize=64m

```

But then I got gc logs in three locations.

Anyone knows how to stop the gc-logs from being written to default location `elasticsearch-8.13.4\logs\`?

---

<div class="post-metadata">

**Author:** ![kg.sterneberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kg.sterneberg/32/134928_2.png) [@kg.sterneberg](https://discuss.elastic.co/u/kg.sterneberg)\
**Post date:** [May 30, 2024, 8:50am UTC](https://discuss.elastic.co/t/gc-logs-written-to-multiple-locations/360542/2 "2024-05-30T08:50:29Z")

</div>

By the way, Elasticsearch 8 did not start at first when the service user (I have installed Elasticsearch as a service in Windows), did not have access to default location `elasticsearch-8.13.4\logs\`. I gave the service user write-permissions to `elasticsearch-8.13.4\logs\`, then Elasticsearch could start but wrote logs to this directory which I do not expect. Why does this happen?

---

<div class="post-metadata">

**Author:** ![kg.sterneberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kg.sterneberg/32/134928_2.png) [@kg.sterneberg](https://discuss.elastic.co/u/kg.sterneberg)\
**Post date:** [May 30, 2024, 9:05am UTC](https://discuss.elastic.co/t/gc-logs-written-to-multiple-locations/360542/3 "2024-05-30T09:05:34Z")

</div>

Seems like gc logs are written to default log location only at startup. Could it be that Elastcsearch 8 creates gc logs before reading configuration?

---

<div class="post-metadata">

**Author:** ![kg.sterneberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kg.sterneberg/32/134928_2.png) [@kg.sterneberg](https://discuss.elastic.co/u/kg.sterneberg)\
**Post date:** [May 30, 2024, 9:30am UTC](https://discuss.elastic.co/t/gc-logs-written-to-multiple-locations/360542/4 "2024-05-30T09:30:18Z")

</div>

Issue solved, Elasticsearch 8 obviously reads `<ES_PATH_CONF>\jvm.options`, creates a gc log in the directory specified in `<ES_PATH_CONF>\jvm.options`, then reads `<ES_PATH_CONF>\jvm.options.d\jvm.options` and applies the new settings for gc logging.
