Skip to content

Revisit log4j2 Message.getFormat() deprecation for v9 #6377

Todo

Description

@runningcode

Log4j 2.24.0 deprecated org.apache.logging.log4j.message.Message.getFormat(), and sentry-log4j2 still calls it to get the unformatted message template. The deprecation warning is suppressed in #5435 (log4j2 2.20.0 → 2.26.1) to keep the build passing under -Xlint:all -Werror.

  • Call sites: SentryAppender.captureLog (populates the sentry.message.template log attribute) and SentryAppender.createEvent (sets Message.message on events) in sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java.
  • The deprecation note points to MultiformatMessage for implementing messages. It does not offer a replacement for reading a message's template, and getFormattedMessage() drops the template.
  • In 2.26.1 the interface method is a default that returns null. Concrete classes such as ParameterizedMessage, ReusableParameterizedMessage, StringFormattedMessage, MessageFormatMessage and SimpleMessage still override it without a deprecation.
  • Log4j 3 has only reached 3.0.0-beta3; no stable 3.0 is listed in the Apache release catalog.

Proposed by Nelson Osacky: suppress the warning now and revisit the call in the next major.

Action taken on behalf of Nelson Osacky.

Activity

  1. linear-code commented on Oct 26, 2026

    @linear-code
  2. ramanathan1504 commented on Dec 4, 2026

    @ramanathan1504

    One thing the deprecation note does not say apache/logging-log4j2#2773 deprecated getFormat() because each message type returns something different, and that already reaches Sentry. Running SentryAppender from main (1f96f3d94) on Log4j 2.26.1, three message types send a wrong template today. A helper that calls getFormat() only for ReusableMessage, ParameterizedMessage, StringFormattedMessage, MessageFormatMessage, FormattedMessage and SimpleMessage, with the single suppression, fixes them and leaves all other logging unchanged.

    Logging call sentry.message.template / event message today With the helper
    info(new StringMapMessage().with("k", "v")) "" / "" absent / absent
    info(new StructuredDataMessage("id1", "sd text", "audit")) sd text / sd text absent / absent
    info(new ObjectMessage(42)) 42 / 42 absent / absent
  3. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions