# How to collect \`log.error\`(slf4j) into the Elastic APM "Error" app?

**URL:** <https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009>\
**Category:** APM\
**Tags:** java\
**Created:** [January 2, 2021, 2:24am UTC](https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009 "2021-01-02T02:24:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![fzyzcjy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fzyzcjy/32/78628_2.png) [@fzyzcjy](https://discuss.elastic.co/u/fzyzcjy)\
**Post date:** [January 2, 2021, 2:24am UTC](https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009/1 "2021-01-02T02:24:44Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

TIP 1: select at least one tag that further categorizes your topic. For example `server` for APM Server related questions, `java` for questions regarding the Elastic APM Java agent, or `ui` for questions about the APM App within Kibana.

TIP 2: Check out the [troubleshooting guide](https://www.elastic.co/guide/en/apm/get-started/current/troubleshooting.html) first. Not only will it help you to resolve common problems faster but it also explains in more detail which information we need before we can properly help you.

**Kibana version** : 7.9

**Elasticsearch version** : 7.9

**APM Server version** : 7.9

**APM Agent language and version** : 1.x

**Browser version** : N/A

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: kubernetes/docker

**Fresh install or upgraded from other version?** N/A

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

I setup by `JAVA_TOOL_OPTIONS` environment variable, with values such as `-javaagent:/elastic/apm/agent/elastic-apm-agent.jar`.

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

Thanks for the product! I wonder how to collect `log.error`(slf4j) into the Elastic APM "Error" app? For example, I know that, when I `throw new RuntimeException("hello")`, the elastic APM will notice it, and I can see it in the APM "Errors" app in Kibana. However, when I do something like `log.error("ouch apple={}", apple, e);`, how can I see it in APM "Errors" app?

**Steps to reproduce** :

1. N/A

**Errors in browser console (if relevant)**: N/A

**Provide logs and/or server output (if relevant)**: N/A

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [January 3, 2021, 10:15am UTC](https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009/2 "2021-01-03T10:15:42Z")

</div>

> [@fzyzcjy](#):
>
> However, when I do something like `log.error("ouch apple={}", apple, e);` , how can I see it in APM "Errors" app?

As far as I remember, this usage of the logger doesn't treat `e` as a `Throwable`, but as a parameter, assuming that the first argument is a parametrized message (ignored in this case because there is only one parameter in the provided message). Therefore, the agent doesn't treat it as a `Throwable` either.  
If you use `log.error("ouch apple=apple", e)`, you should get an error reported for that.

---

<div class="post-metadata">

**Author:** ![fzyzcjy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fzyzcjy/32/78628_2.png) [@fzyzcjy](https://discuss.elastic.co/u/fzyzcjy)\
**Post date:** [January 3, 2021, 11:30am UTC](https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009/3 "2021-01-03T11:30:04Z")

</div>

Nice catch! I did not thought of that. After reading the code I do see so. Thanks!

---

<div class="post-metadata">

**Author:** ![fzyzcjy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fzyzcjy/32/78628_2.png) [@fzyzcjy](https://discuss.elastic.co/u/fzyzcjy)\
**Post date:** [January 7, 2021, 2:58am UTC](https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009/4 "2021-01-07T02:58:37Z")

</div>

@Eyal_Koren By the way, I wonder whether `log.warn("str", e)` will also be captured by elastic APM or not? Thanks!

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [January 7, 2021, 7:43am UTC](https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009/5 "2021-01-07T07:43:18Z")

</div>

> [@fzyzcjy](#):
>
> I wonder whether `log.warn("str", e)` will also be captured by elastic APM or not?

No, if a user doesn't consider something as error, we wouldn't want to do that.

---

<div class="post-metadata">

**Author:** ![fzyzcjy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fzyzcjy/32/78628_2.png) [@fzyzcjy](https://discuss.elastic.co/u/fzyzcjy)\
**Post date:** [January 8, 2021, 6:36am UTC](https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009/6 "2021-01-08T06:36:03Z")

</div>

Hmm though sounds not that helpful to my case, thanks!

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [January 11, 2021, 6:18am UTC](https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009/7 "2021-01-11T06:18:27Z")

</div>

> [@fzyzcjy](#):
>
> Hmm though sounds not that helpful to my case, thanks!

Well, sorry about that...  
In case you are not familiar, we have a public API that allows you to extend automatic tracing based on your specific needs, including the ability to [capture an Exception](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-span-capture-exception) in the correct span/transaction context.

---

<div class="post-metadata">

**Author:** ![fzyzcjy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fzyzcjy/32/78628_2.png) [@fzyzcjy](https://discuss.elastic.co/u/fzyzcjy)\
**Post date:** [January 19, 2021, 3:59am UTC](https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009/8 "2021-01-19T03:59:10Z")

</div>

Hmm thanks all the same!

---

<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 8, 2021, 11:59pm UTC](https://discuss.elastic.co/t/how-to-collect-log-error-slf4j-into-the-elastic-apm-error-app/260009/9 "2021-02-08T23:59:44Z")

</div>

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