Legacy Knowledge Base
Published Sep. 10, 2025

Brave log-correlation issue

Written By

Ahmed Abdin

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • I am using brave (https://github.com/openzipkin/brave) to create a correlation across all logs events from Liferay, portlets and backends. After upgrading from Liferay 7.2 to 2024.Q3.12, which now internally uses log4j2 v2.17.1, I am missing the information taceId and spanId in most of our logs from Liferay portlets. To insert the information into all log outputs, %X{traceId} and %X{spanId} are placeholders that log4j resolves at runtime and retrieves the corresponding values from the org.apache.logging.log4j.ThreadContext.

    Brave provides a special library (io.zipkin.brave:brave-context-log4j2) that writes the current taceId and spanId to the ThreadContext of log4j. This works in principle, as some of their logs also contain this information. But in most cases they are missing.

    After some research, the customer found the class com.liferay.portal.log.Log4jLogContextLogWrapper in the Liferay code, which also uses the org.apache.logging.log4j.ThreadContext. This class hooks into all log events of Liferay in order to also place information in the ThreadContext. But after logging, the context is unfortunately deleted completely (method _cleanThreadContext()). This means that their traceId and spanId are also lost with the first internal Liferay log

Environment

  • Liferay Quarterly Release 2024.q3.12

Resolution

  • The case is resolved by LPD-18800. Please request a hotfix.
Did this article resolve your issue ?

Legacy Knowledge Base