Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrote Messages #2591

Merged
merged 6 commits into from
May 24, 2024
Merged

Rewrote Messages #2591

merged 6 commits into from
May 24, 2024

Conversation

grobmeier
Copy link
Member

@grobmeier grobmeier commented May 16, 2024

Messages

@grobmeier grobmeier self-assigned this May 16, 2024
@grobmeier grobmeier mentioned this pull request May 16, 2024
5 tasks
@vy
Copy link
Member

vy commented May 17, 2024

@grobmeier, I once started rewriting this, and back then drafted the following intro:

Although Log4j provides `Logger` methods that accept a formatting pattern of type `String` and its parameters of type `Object`, all of these are ultimately captured in link:../javadoc/log4j-api/org/apache/logging/log4j/message/Message.html[`Message`] objects that are attached to the generated log event:

[source,java]
----
LOGGER.info("Everything is awesome!");
LOGGER.info("Party time for `{}`", userName);
----

is analogous to

[source,java]
----
LOGGER.info(new SimpleMessage("Everything is awesome!"));
LOGGER.info(new ParameterizedMessage("Party time for `{}`", new Object[]{userId}));
----

Here I like the way readers are demonstrated with how LOGGER.foo(bar) under-the-hood translates to LOGGER.foo(new Message(bar)). Maybe you can use this. 👼

Caution: "is analogous to" phrase is important here, since it is not "identical to"! That is, we actually use reusable messages under-the-hood, but this detail is irrelevant in this context.

@grobmeier grobmeier marked this pull request as ready for review May 19, 2024 15:57
@grobmeier grobmeier requested review from vy and ppkarwasz May 19, 2024 15:57
@vy
Copy link
Member

vy commented May 24, 2024

As agreed with @grobmeier, merging this to wrap up the work on API docs.

@vy vy merged commit 248be8d into 2.x May 24, 2024
9 checks passed
@vy vy deleted the doc/2.x/manual-messages-2535 branch May 24, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants