# How can i configure log4j to use AsyncAppender instead SocketAppender?

**URL:** https://discuss.elastic.co/t/how-can-i-configure-log4j-to-use-asyncappender-instead-socketappender/89951
**Category:** Elasticsearch
**Created:** [June 19, 2017, 2:38pm UTC](https://discuss.elastic.co/t/how-can-i-configure-log4j-to-use-asyncappender-instead-socketappender/89951 "2017-06-19T14:38:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mvleandro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvleandro/32/14268_2.png) [@mvleandro](https://discuss.elastic.co/u/mvleandro)
#### Post date: [June 19, 2017, 2:38pm UTC](https://discuss.elastic.co/t/how-can-i-configure-log4j-to-use-asyncappender-instead-socketappender/89951/1 "2017-06-19T14:38:09Z")

</div>

Hi guys,

I found this thread from 2015 [Elasticsearch AsyncAppender configuration](https://discuss.elastic.co/t/elasticsearch-asyncappender-configuration/22213) and this another from 19d ago [Log4j2 AsyncAppender in Elasticsearch 5.x](https://discuss.elastic.co/t/log4j2-asyncappender-in-elasticsearch-5-x/87732) and my question is: It's possible to configure AsyncAppender on ES 5.x?

The configuration from the first link still valid?

---

<div class="post-metadata">

### Author: ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)
#### Post date: [June 19, 2017, 3:21pm UTC](https://discuss.elastic.co/t/how-can-i-configure-log4j-to-use-asyncappender-instead-socketappender/89951/2 "2017-06-19T15:21:12Z")

</div>

Are you sure you want to do that?

Using `AsyncAppender` will cause logging messages to buffer into memory that goes straight to heap (iirc) and will eventually cause memory pressure issues (i.e. long GCs). Which is very problematic to overall cluster performance and stability.

Elasticsearch logging at `INFO` level is very quiet and should not be the cause of any I/O bottleneck.

---

<div class="post-metadata">

### Author: ![mvleandro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvleandro/32/14268_2.png) [@mvleandro](https://discuss.elastic.co/u/mvleandro)
#### Post date: [June 19, 2017, 9:41pm UTC](https://discuss.elastic.co/t/how-can-i-configure-log4j-to-use-asyncappender-instead-socketappender/89951/3 "2017-06-19T21:41:26Z")

</div>

Thank you Thiago.

I've changed my logging configuration to INFO and i'll observe.

---

<div class="post-metadata">

### Author: ![tvlieg](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@tvlieg](https://discuss.elastic.co/u/tvlieg)
#### Post date: [June 20, 2017, 2:49pm UTC](https://discuss.elastic.co/t/how-can-i-configure-log4j-to-use-asyncappender-instead-socketappender/89951/4 "2017-06-20T14:49:37Z")

</div>

Hi! I posted the issue from 19 days ago. I believe we actually do need asynchronous appending:

We have a setup with Elasticsearch logging to a Redis queue. Suppose the ES loglevel would temporarily be changed to DEBUG (or maybe even TRACE) and there would also be network issues in between ES and Redis. If a synchronous appender would be used, then in this setup the logging would actually render the cluster to be very slow/unresponsive because it would have to wait for all logs to be processed, before getting to continue its normal operations.

Or is there something I'm missing/does ES solve this in a different way?

---

<div class="post-metadata">

### Author: ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)
#### Post date: [June 21, 2017, 2:35pm UTC](https://discuss.elastic.co/t/how-can-i-configure-log4j-to-use-asyncappender-instead-socketappender/89951/5 "2017-06-21T14:35:17Z")

</div>

@tvlieg I understand what you mean and indeed enabling TRACE and DEBUG with synchronous may impose _some_ performance impact but I don't think it pays off the performance issues you would have if async is used and heap gets flooded with logging messages because disk can not keep up with it.

Anyway, I have yet to see a situation that enabling DEBUG and TRACE in production with sync logging would severely impact cluster performance. When you enable that logging level it is generally because you have bigger issues going on.

---

<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 19, 2017, 2:35pm UTC](https://discuss.elastic.co/t/how-can-i-configure-log4j-to-use-asyncappender-instead-socketappender/89951/6 "2017-07-19T14:35:18Z")

</div>

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