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

[2.0.x] parameter with value {} is replaced with null #516

Closed
rastislavpapp opened this issue Mar 24, 2023 · 4 comments
Closed

[2.0.x] parameter with value {} is replaced with null #516

rastislavpapp opened this issue Mar 24, 2023 · 4 comments
Assignees
Labels
Milestone

Comments

@rastislavpapp
Copy link

environment - karaf 4.4.3, pax logging 2.2.0, using slf4j api and log4j2 implementation

problem:

log.info("ABC {} DEF", "test{}test");

outputs:

ABC testnulltest DEF
@grgrzybek grgrzybek self-assigned this Mar 24, 2023
@grgrzybek grgrzybek added the type: bug Bug label Mar 24, 2023
@grgrzybek grgrzybek added this to the 2.2.3 milestone Mar 24, 2023
@grgrzybek
Copy link
Member

grgrzybek commented Mar 24, 2023

Thanks for report - I'll check soon.

@grgrzybek
Copy link
Member

Just a question - how did you obtain the log instance? what's the class of this instance?

@rastislavpapp
Copy link
Author

log instance is obtained via

this.log = org.slf4j.LoggerFactory.getLogger(loggerName);

and it is an instance of org.ops4j.pax.logging.slf4j.Slf4jLogger

as I've investigated a little further, in the Slf4jLogger the message gets formatted correctly, via these calls:

 FormattingTuple tuple = MessageFormatter.arrayFormat(format, argArray);
m_delegate.debug(m, tuple.getMessage(), tuple.getThrowable());

after this, tuple.getMessage() returns "ABC test{}test DEF", but then it is formatted again in PaxLoggerImpl:

FormattingTriple ft = FormattingTriple.discover(format, false, arg);
doLog(marker.log4j2Marker(), Level.DEBUG, m_fqcn, ft.getMessage(), ft.getThrowable(), ft.getServiceReference(), ft.getArgArray());

After this, ft.getMessage() returns "ABC testnulltest DEF", I guess it took the {} as a place to put an exception (which is not present as a last argument, so it is null)

@grgrzybek grgrzybek changed the title parameter with value {} is replaced with null [2.0.x] parameter with value {} is replaced with null Mar 27, 2023
@grgrzybek
Copy link
Member

@rastislavpapp I've fixed this issue in 2.2.x branch - thank you very much for spotting, because it wass quite serious bug.

If you need a release, just let me know ;)

cc: @jbonofre

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants