# Add transaction id, to incoming request, and log it in access log (Spring Boot with Tomcat)

**URL:** <https://discuss.elastic.co/t/add-transaction-id-to-incoming-request-and-log-it-in-access-log-spring-boot-with-tomcat/295482>\
**Category:** APM\
**Tags:** java\
**Created:** [January 26, 2022, 4:10pm UTC](https://discuss.elastic.co/t/add-transaction-id-to-incoming-request-and-log-it-in-access-log-spring-boot-with-tomcat/295482 "2022-01-26T16:10:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Casper\_Thrane](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casper_thrane/32/49777_2.png) [@Casper\_Thrane](https://discuss.elastic.co/u/Casper_Thrane)\
**Post date:** [January 26, 2022, 4:10pm UTC](https://discuss.elastic.co/t/add-transaction-id-to-incoming-request-and-log-it-in-access-log-spring-boot-with-tomcat/295482/1 "2022-01-26T16:10:11Z")

</div>

Hi

Is it possible to add a transaction/trace id to the incoming http request, and log it, in the access log. All other logs, we use log4j2, and here these ids is automatically logged. We would like to be able, to correlate our access logs, with our application logs.

Br Casper

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [January 26, 2022, 6:10pm UTC](https://discuss.elastic.co/t/add-transaction-id-to-incoming-request-and-log-it-in-access-log-spring-boot-with-tomcat/295482/2 "2022-01-26T18:10:05Z")

</div>

Hi and thanks for the question.

No, this is not possible at the moment. It would also be very hard to do. Some of the challenges are:

- Tomcat doesn't use a standard log library for the access log. See also [tomcat/AbstractAccessLogValve.java at a05603de0fc5ae1ee60d41ea8677f96818a9b11f · apache/tomcat · GitHub](https://github.com/apache/tomcat/blob/a05603de0fc5ae1ee60d41ea8677f96818a9b11f/java/org/apache/catalina/valves/AbstractAccessLogValve.java#L695).
- At the point in time where Tomcat is logging the request, the Java agent hasn't created a Transaction yet
- Adding the trace ids may break tools that rely on the well-known format of Tomcat's access logs.

---

<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 16, 2022, 2:10pm UTC](https://discuss.elastic.co/t/add-transaction-id-to-incoming-request-and-log-it-in-access-log-spring-boot-with-tomcat/295482/3 "2022-02-16T14:10:59Z")

</div>

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