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

Fluent logging of primitive types #375

Open
Webbot99 opened this issue Dec 10, 2023 · 3 comments
Open

Fluent logging of primitive types #375

Webbot99 opened this issue Dec 10, 2023 · 3 comments

Comments

@Webbot99
Copy link

When using LoggingEventBuilder to addArgument or addKeyValue the only parameter options are Object or Supplier. If I use any primitive type (boolean, char, byte, short, int, long, float, double) then the compiler autoboxes them, even when the specified log level is not enabled and the Nop builder then discards them. This can generate a lot of eden garbage. This is an issue for me as I am working on a high throughput, garbage free, app which deals primarily in primitive types.
Adding these variants as additional methods eg addKeyValue("Foo", 1.23d) etc would delay the auto boxing until when, and only when, the logging is going to output something.
Currently the only surefire way to avoid this is to wrap such logging within an is<Level>Enabled block.

@Webbot99
Copy link
Author

Webbot99 commented Dec 10, 2023

Related to #367
Which suggests using a Supplier of the primitive type does not help

@ceki
Copy link
Member

ceki commented Dec 22, 2023

@Webbot99 Thank you for this report. SLF4J 2.1.0-alpha0 to be released within the next few days will add default arg(boolean), arg(byte), arg(short)... methods to the LoggingEventBuilder interface with NOP implementations in NOPLoggingEventBuilder.

See the changes to LoggingEventBuilder in commit 154b4e4 for details.

@ceki
Copy link
Member

ceki commented Dec 22, 2023

See the changes to LoggingEventBuilder in commit 154b4e4 for details.

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

No branches or pull requests

2 participants