# Best way to enable GC logging (as of 2.x)

**URL:** <https://discuss.elastic.co/t/best-way-to-enable-gc-logging-as-of-2-x/36784>\
**Category:** Elasticsearch\
**Created:** [December 9, 2015, 6:54pm UTC](https://discuss.elastic.co/t/best-way-to-enable-gc-logging-as-of-2-x/36784 "2015-12-09T18:54:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)\
**Post date:** [December 9, 2015, 6:54pm UTC](https://discuss.elastic.co/t/best-way-to-enable-gc-logging-as-of-2-x/36784/1 "2015-12-09T18:54:20Z")

</div>

Hello,

I looked at many sources for enabling GC logging, so much confusion.

What is the best way to enable this?

- In elasticsearch.yml file via monitor.jvm.\* values?
- In /etc/sysconfig/elasticsearch ES\_JAVA\_OPTS? What to put there?

Is it a good thing to always enable this, even if we're not currently under memory pressure ?  
Just to be cautious.

If enabled, how to keep just a certain amount of log files?

Thanks  
Bruno Lavoie

---

<div class="post-metadata">

**Author:** ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)\
**Post date:** [December 10, 2015, 1:07pm UTC](https://discuss.elastic.co/t/best-way-to-enable-gc-logging-as-of-2-x/36784/2 "2015-12-10T13:07:07Z")

</div>

Anyone?  
I just want to do it, the right way. 🙂

---

<div class="post-metadata">

**Author:** ![bleskes](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@bleskes](https://discuss.elastic.co/u/bleskes)\
**Post date:** [December 10, 2015, 2:32pm UTC](https://discuss.elastic.co/t/best-way-to-enable-gc-logging-as-of-2-x/36784/3 "2015-12-10T14:32:42Z")

</div>

What are you trying to achieve exactly? if you want ES log when a GC took longer than X time, and you are note happy with the default, you can put the following in your elasticsearch.yml file (the numbers here show the default values)

```
monitor.jvm.gc.young.warn: 1000ms
monitor.jvm.gc.young.info: 700ms
monitor.jvm.gc.young.debug: 400ms

monitor.jvm.gc.old.warn: 10s
monitor.jvm.gc.old.info: 5s
monitor.jvm.gc.old.debug: 2s
```

---

<div class="post-metadata">

**Author:** ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)\
**Post date:** [December 10, 2015, 6:59pm UTC](https://discuss.elastic.co/t/best-way-to-enable-gc-logging-as-of-2-x/36784/4 "2015-12-10T18:59:25Z")

</div>

First of all, thanks for replying.

> [@bleskes](#):
>
> What are you trying to achieve exactly? if you want ES log when a GC took longer than X time, and you are note happy with the default, you can put the following in your elasticsearch.yml file (the numbers here show the default values)

Ok, so I saw these default values in pre-2.x config files.

Just putting these lines will activate slow GCs?  
Or is it already activated by default with these values and will be logged?  
GC info logged in which file?  
Should I turn some other flags, like putting something in ES\_JAVA\_OPTS?

I just want to be ready in case of slow GC and have all necessary information necessary at hand.

Thanks

---

<div class="post-metadata">

**Author:** ![bleskes](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@bleskes](https://discuss.elastic.co/u/bleskes)\
**Post date:** [December 14, 2015, 8:09pm UTC](https://discuss.elastic.co/t/best-way-to-enable-gc-logging-as-of-2-x/36784/5 "2015-12-14T20:09:20Z")

</div>

These are the defaults and they are already active. The output is logged in the same log file as the rest of the log output. Typically in logs/CLUSTERNAME.log

---

<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 5, 2017, 11:31pm UTC](https://discuss.elastic.co/t/best-way-to-enable-gc-logging-as-of-2-x/36784/6 "2017-07-05T23:31:11Z")

</div>


