# Configure app logging in APM

**URL:** <https://discuss.elastic.co/t/configure-app-logging-in-apm/302019>\
**Category:** APM\
**Tags:** docker, server\
**Created:** [April 9, 2022, 9:49am UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019 "2022-04-09T09:49:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raushan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raushan/32/102180_2.png) [@Raushan](https://discuss.elastic.co/u/Raushan)\
**Post date:** [April 9, 2022, 9:49am UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019/1 "2022-04-09T09:49:38Z")

</div>

**Kibana version** : 8.0.0

**Elasticsearch version** : 8.0.0

**APM Server version** : 8.0.0

**APM Agent language and version** : Java & 1.29.0

**Browser version** : Chrome

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

**Fresh install or upgraded from other version?** Fresh

**Is there anything special in your setup?** No

**Steps to reproduce** :  
I have deployed apm server, with ES and KB on Azure.  
I have Java app where i configured apm agent.  
On APM app, I'm not able to see logs.  
How can i transfer app logs

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/d/8d186f4f69dfb4cb65e88dee1481c84138fcd662.png)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/c/dc16016f4f6c7b2f5930adb4a315697d7f6c966f.png)

---

<div class="post-metadata">

**Author:** ![zx8086](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zx8086/32/94917_2.png) [@zx8086](https://discuss.elastic.co/u/zx8086)\
**Post date:** [April 9, 2022, 11:59am UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019/2 "2022-04-09T11:59:00Z")

</div>

The java app configuration, at startup should tell you if you have connected to the APM Server... are you verifying this?

If you have no data... there is an error logged somewhere or a misconfiguration. How is your java app configured with apm agent ?

---

<div class="post-metadata">

**Author:** ![Raushan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raushan/32/102180_2.png) [@Raushan](https://discuss.elastic.co/u/Raushan)\
**Post date:** [April 9, 2022, 12:18pm UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019/3 "2022-04-09T12:18:41Z")

</div>

Yeah, from java app logs, it says to be connected

```auto
exec java -XX:MinRAMPercentage=70 -XX:MaxRAMPercentage=70 -javaagent:/app/apm-agent.jar -Delastic.apm.server_url=https://10.0.0.0:8200 -Delastic.apm.verify_server_cert=false -Delastic.apm.service_name=apm-rules-data -Delastic.apm.application_packages=com.test --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED -jar rules.jar
[main] INFO co.elastic.apm.agent.util.JmxUtils - Found JVM-specific OperatingSystemMXBean interface: com.sun.management.OperatingSystemMXBean
[main] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.29.0 as apm-rules-data (0.0.1-SNAPSHOT) on Java 17.0.2 Runtime version: 17.0.2+8-86 VM version: 17.0.2+8-86 (Oracle Corporation) Linux 5.4.0-1069-azure
[main] INFO co.elastic.apm.agent.configuration.StartupInfo - service_name: 'apm-rules-data' (source: Java System Properties)
[main] INFO co.elastic.apm.agent.configuration.StartupInfo - server_url: 'https://10.0.0.0:8200' (source: Java System Properties)
[main] INFO co.elastic.apm.agent.configuration.StartupInfo - verify_server_cert: 'false' (source: Java System Properties)
[main] INFO co.elastic.apm.agent.configuration.StartupInfo - application_packages: 'com.test' (source: Java System Properties)
[main] INFO co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to RUNNING state
[elastic-apm-server-healthcheck] INFO co.elastic.apm.agent.report.ApmServerHealthChecker - Elastic APM server is available: { "build_date": "2022-02-03T16:50:25Z", "build_sha": "6afb387ae002e5a8dc2427b53225aa42681e4208", "publish_ready": true, "version": "8.0.0"}
[elastic-apm-remote-config-poller] INFO co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Received new configuration from APM Server: {}

```

APP is configured manually with apm agent

```auto
JAVA_OPTS="${JAVA_OPTS} -javaagent:/app/apm-agent.jar"
JAVA_OPTS="${JAVA_OPTS} -Delastic.apm.server_url=${APM_SERVER_URI}"
JAVA_OPTS="${JAVA_OPTS} -Delastic.apm.verify_server_cert=false"
JAVA_OPTS="${JAVA_OPTS} -Delastic.apm.service_name=apm-rules-data"
JAVA_OPTS="${JAVA_OPTS} -Delastic.apm.application_packages=com.test"

```

At least it should show server start up logs, right?

---

<div class="post-metadata">

**Author:** ![zx8086](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zx8086/32/94917_2.png) [@zx8086](https://discuss.elastic.co/u/zx8086)\
**Post date:** [April 9, 2022, 1:28pm UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019/4 "2022-04-09T13:28:42Z")

</div>

The AMM agent is registered correctly with the Service Name so that is good. it seems more that there are no transactions or spans to send ? This is more to do with your application, you can turn on the debug for more details on if your java application is sending anything.

---

<div class="post-metadata">

**Author:** ![Raushan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raushan/32/102180_2.png) [@Raushan](https://discuss.elastic.co/u/Raushan)\
**Post date:** [April 9, 2022, 2:05pm UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019/5 "2022-04-09T14:05:05Z")

</div>

HealthCheck is basic transaction which is logging at INFO level and can be seen in app log.  
Same transaction and traces is present in APM.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/f/6f86d8f61efd805475badcb907eb824fecdef4a8.png)  
logs

```auto
2022-04-09 14:02:34,524 http-nio-9001-exec-6 INFO com.test.rules.controller.RulesController: Health check ok
2022-04-09 14:02:41,553 http-nio-9001-exec-7 INFO com.test.rules.controller.RulesController: Health check ok
2022-04-09 14:03:04,524 http-nio-9001-exec-8 INFO com.test.rules.controller.RulesController: Health check ok
2022-04-09 14:03:11,553 http-nio-9001-exec-9 INFO com.test.rules.controller.RulesController: Health check ok

```

**Is there any other configuration need to be done on APM to poll the logs?** eg: Fleet agent?

I think, logging integration is required to embedd logs into the APM UI. But how 🤔 🤔

---

<div class="post-metadata">

**Author:** ![zx8086](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zx8086/32/94917_2.png) [@zx8086](https://discuss.elastic.co/u/zx8086)\
**Post date:** [April 9, 2022, 2:34pm UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019/6 "2022-04-09T14:34:01Z")

</div>

If something is being registered, then the APM agent seems fine, maybe this is your application issue ?

> **[Log correlation | APM Java Agent Reference \[1.x\] | Elastic](https://www.elastic.co/guide/en/apm/agent/java/current/log-correlation.html)**

> **[API/Code | APM Java Agent Reference \[1.x\] | Elastic](https://www.elastic.co/guide/en/apm/agent/java/current/method-api.html)**

---

<div class="post-metadata">

**Author:** ![Raushan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raushan/32/102180_2.png) [@Raushan](https://discuss.elastic.co/u/Raushan)\
**Post date:** [April 12, 2022, 7:18am UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019/7 "2022-04-12T07:18:05Z")

</div>

> [@zx8086](#):
>
> hen the APM agent seems fine, maybe this is your application issue ?

What i understood from logs is, we need to app logs in ES to correlate with APM

So i used fluent bit to send logs to ES

Now, how can we correlate fluent bit logs to APM logs?

---

<div class="post-metadata">

**Author:** ![zx8086](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zx8086/32/94917_2.png) [@zx8086](https://discuss.elastic.co/u/zx8086)\
**Post date:** [April 12, 2022, 7:22am UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019/8 "2022-04-12T07:22:39Z")

</div>

Normally this will be via the timestamp, but for proper instrumentation, there should be a correlation id present in both the APM & Logs.

---

<div class="post-metadata">

**Author:** ![Raushan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raushan/32/102180_2.png) [@Raushan](https://discuss.elastic.co/u/Raushan)\
**Post date:** [April 12, 2022, 9:59am UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019/9 "2022-04-12T09:59:47Z")

</div>

Please see i have transaction id in metadata of APM transaction and In Kibana we have logs for this transaction id, still it does n't show in APM logs

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/2/4271db21a363472c8b3fc42aa49fb1e712bc3920.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/e/1eaa1c3c1a3e339994c16e4ce4d0d63173c7c288.png)  
**Streams are not present and logs are not correlating**  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/7/27073a0375e2a4d7f4cd4745d1d4d431e7766601.png)

---

<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:** [May 3, 2022, 6:00am UTC](https://discuss.elastic.co/t/configure-app-logging-in-apm/302019/10 "2022-05-03T06:00:04Z")

</div>

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