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

LogManager FORMAT_FAILURE on application startup #12615

Closed
jamesnetherton opened this issue Oct 9, 2020 · 12 comments · Fixed by #12619
Closed

LogManager FORMAT_FAILURE on application startup #12615

jamesnetherton opened this issue Oct 9, 2020 · 12 comments · Fixed by #12619
Labels
kind/bug Something isn't working
Milestone

Comments

@jamesnetherton
Copy link
Contributor

Describe the bug

Relates to apache/camel-quarkus#1891.

Since upgrading to Quarkus 1.9.0.CR1, I noticed errors on some of the camel-quarkus integration tests. It seems to be related to logging. In our camel-jira integration test, there's a point where Camel is trying to log the name & value of a configuration property. It results in:

2020-10-08T08:32:32.2091764Z LogManager error of type FORMAT_FAILURE: Formatting error
2020-10-08T08:32:32.2099488Z java.lang.IllegalArgumentException: can't parse argument number: {env:JIRA_PASSWORD:s3cr3t}
2020-10-08T08:32:32.2106490Z 	at java.base/java.text.MessageFormat.makeFormat(MessageFormat.java:1451)
2020-10-08T08:32:32.2135815Z 	at java.base/java.text.MessageFormat.applyPattern(MessageFormat.java:491)
2020-10-08T08:32:32.2137278Z 	at java.base/java.text.MessageFormat.<init>(MessageFormat.java:370)
2020-10-08T08:32:32.2138476Z 	at java.base/java.text.MessageFormat.format(MessageFormat.java:859)
2020-10-08T08:32:32.2140257Z 	at org.jboss.logmanager.ExtFormatter.formatMessageLegacy(ExtFormatter.java:107)
2020-10-08T08:32:32.2142371Z 	at org.jboss.logmanager.ExtFormatter.formatMessage(ExtFormatter.java:70)
2020-10-08T08:32:32.2146855Z 	at org.jboss.logmanager.formatters.Formatters$16.renderRaw(Formatters.java:781)
2020-10-08T08:32:32.2148459Z 	at org.jboss.logmanager.formatters.Formatters$JustifyingFormatStep.render(Formatters.java:221)
2020-10-08T08:32:32.2150571Z 	at org.jboss.logmanager.formatters.MultistepFormatter.format(MultistepFormatter.java:86)
2020-10-08T08:32:32.2156574Z 	at org.jboss.logmanager.ExtFormatter.format(ExtFormatter.java:32)
2020-10-08T08:32:32.2160057Z 	at org.jboss.logmanager.handlers.WriterHandler.doPublish(WriterHandler.java:43)
2020-10-08T08:32:32.2161768Z 	at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:66)
2020-10-08T08:32:32.2163405Z 	at org.jboss.logmanager.handlers.DelayedHandler.publishToChildren(DelayedHandler.java:208)
2020-10-08T08:32:32.2166475Z 	at org.jboss.logmanager.handlers.DelayedHandler.doPublish(DelayedHandler.java:49)
2020-10-08T08:32:32.2174299Z 	at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:66)
2020-10-08T08:32:32.2179223Z 	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:316)
2020-10-08T08:32:32.2182231Z 	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
2020-10-08T08:32:32.2193551Z 	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
2020-10-08T08:32:32.2194754Z 	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
2020-10-08T08:32:32.2196247Z 	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
2020-10-08T08:32:32.2197233Z 	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
2020-10-08T08:32:32.2206325Z 	at org.jboss.logmanager.Logger.logRaw(Logger.java:748)
2020-10-08T08:32:32.2207408Z 	at org.jboss.logmanager.Logger.log(Logger.java:706)
2020-10-08T08:32:32.2208843Z 	at org.jboss.logging.JBossLogManagerLogger.doLog(JBossLogManagerLogger.java:44)

The source of the config value is here. It looks like the '{' & '}' characters are possibly causing the problem.

I wonder if the slf4j-jboss-logging upgrade to 1.2.1.Final is the problem? If force a downgrade back to 1.2.0.Final, the problem does not occur.

I did a quick scan of the Quarkus CI build log and noticed a similar exception being thrown in SentryLoggerDisabledTest.

The tests still pass ok, there's just the ugly stack trace when the app starts up.

Expected behavior
The desired log message should be printed without errors.

Actual behavior
Logging fails with FORMAT_FAILURE.

To Reproduce

  1. Clone the camel-quarkus project
  2. Build (quickly): mvn clean install -DskipTests -Dquarkus.build.skip -Denforce=false -T1C
  3. Run integration tests

To replicate the error in the linked issue:

mvn clean test -pl :camel-quarkus-integration-test-jira

Same error cause but different stack trace (Note: You'll need Docker running for this one):

mvn clean test -pl :camel-quarkus-integration-test-activemq
@jamesnetherton jamesnetherton added the kind/bug Something isn't working label Oct 9, 2020
@gsmet
Copy link
Member

gsmet commented Oct 9, 2020

I wonder if it could be related to jboss-logging/slf4j-jboss-logging@1204d43 .

I will downgrade in the meantime.

/cc @jamezp

@skasten
Copy link

skasten commented Oct 9, 2020

We experience the same problem, but with 1.8.2.Final.
The problem occurs, if a parameter in the log statement prints out JSON in the toString().
In our case, we have some Avro objects, where these object prints out it JSON serialization on the toString method.
We use SLF4J for logging. We do something like:

SomeAvroObject myAvroObject = ....;
logger.info("Here is a log entry for my object={}", myAvroObject);

For my understanding, toString() on myAvroObject should be called, which returns JSON.
Then some strange things happen, the the LogManager seem to interpret this JSON?!
We get this stack trace:

java.lang.IllegalArgumentException: can't parse argument number: "m2mDeviceId": "313331000000045"
	at java.text.MessageFormat.makeFormat(MessageFormat.java:1429)
	at java.text.MessageFormat.applyPattern(MessageFormat.java:479)
	at java.text.MessageFormat.<init>(MessageFormat.java:362)
	at java.text.MessageFormat.format(MessageFormat.java:840)
	at org.jboss.logmanager.ExtFormatter.formatMessageLegacy(ExtFormatter.java:107)
	at org.jboss.logmanager.ExtFormatter.formatMessage(ExtFormatter.java:70)
	at org.jboss.logmanager.formatters.Formatters$16.renderRaw(Formatters.java:781)
	at org.jboss.logmanager.formatters.Formatters$JustifyingFormatStep.render(Formatters.java:221)
	at org.jboss.logmanager.formatters.MultistepFormatter.format(MultistepFormatter.java:86)
	at io.quarkus.runtime.logging.BannerFormatter.format(BannerFormatter.java:56)
	at org.jboss.logmanager.ExtFormatter.format(ExtFormatter.java:32)
	at org.jboss.logmanager.handlers.WriterHandler.doPublish(WriterHandler.java:43)
	at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:66)
	at org.jboss.logmanager.handlers.DelayedHandler.publishToChildren(DelayedHandler.java:208)
	at org.jboss.logmanager.handlers.DelayedHandler.doPublish(DelayedHandler.java:49)
	at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:66)
	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:316)
	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
	at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:324)
	at org.jboss.logmanager.Logger.logRaw(Logger.java:748)
	at org.jboss.logmanager.Logger.log(Logger.java:706)
	at org.jboss.logging.JBossLogManagerLogger.doLog(JBossLogManagerLogger.java:44)
	at org.jboss.logging.Logger.log(Logger.java:2103)
	at org.jboss.slf4j.JBossLoggerAdapter.log(JBossLoggerAdapter.java:302)
	at org.jboss.slf4j.JBossLoggerAdapter.info(JBossLoggerAdapter.java:196)
	...

Where m2mDeviceId is the first field of the resulting JSON.

I have tested this with 1.5.2, 1.60, 1.7.1, 1.8.0 and 1.8.1 and it works fine.
Upgrade to 1.8.2 causes this issue.

@gsmet
Copy link
Member

gsmet commented Oct 9, 2020

@skasten I suspect downgrading slf4j-jboss-logging to 1.2.0.Final will fix your issue. It was upgraded in 1.8.2.Final.

@skasten
Copy link

skasten commented Oct 9, 2020

@gsmet Yes, with 1.2.0.Final it works.

@gsmet
Copy link
Member

gsmet commented Oct 9, 2020

/cc @dmlloyd too

Interesting comment is there: #12615 (comment) .

gsmet added a commit to gsmet/quarkus that referenced this issue Oct 9, 2020
@gsmet gsmet added this to the 1.10 - master milestone Oct 9, 2020
@gsmet
Copy link
Member

gsmet commented Oct 9, 2020

I just pushed 1.8.3.Final with the downgrade.

@jamezp
Copy link
Contributor

jamezp commented Oct 9, 2020

The reason main reason is this is caused by having abstractions over abstractions :) Since slf4j-jboss-logging is being used it delegates slf4j to jboss-logging which in turn delegates to jboss-logmanager. jboss-logging passes the format parameters to jboss-logmanager and it attempts to format an already formatted message. We pass the parameters though so they end up in the structured formatters like the JSON formatter output.

If there is a slf4j-jboss-logmanager project which would delegate directly to jboss-logmanager. However it would need a minor update now that I look at it. There could be a reason that I don't recall that slf4j-jboss-logging is being used.

@gsmet
Copy link
Member

gsmet commented Oct 13, 2020

I created jboss-logging/slf4j-jboss-logging#15 .

@jamezp
Copy link
Contributor

jamezp commented Oct 13, 2020

@gsmet I think the proper solution will be to switch to using https://github.com/jboss-logging/slf4j-jboss-logmanager/. I made some updates yesterday and can cut a release if it's something you want for Quarkus.

@SlyngDK
Copy link
Contributor

SlyngDK commented Oct 13, 2020

@gsmet @jamezp I am looking at, a solution on switching to https://github.com/jboss-logging/slf4j-jboss-logmanager/, as sugested by @jamezp. I think i have something working local, there is a changed required to the slf4j-jboss-logmanager, and updating the required dependencies in quarkus.
The changes in version 1.2.1.Final of slf4j-jboss-logging, should be rollback.

@SlyngDK
Copy link
Contributor

SlyngDK commented Oct 13, 2020

@jamezp I have created jboss-logging/slf4j-jboss-logmanager#10, to fix the issue I have seen.

@SlyngDK
Copy link
Contributor

SlyngDK commented Oct 13, 2020

#12659 have solve the issue.
I have created a draft PR #12692 on the change of the slf4j implementation.
Test run local looks promising, I will look at the CI results tomorrow.

@gsmet gsmet modified the milestones: 1.9.0.Final, 1.8.3.Final Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants