quarkiverse / quarkus-logging-json

Quarkus logging extension outputting the logging in json.
Apache License 2.0
63 stars 30 forks source link

Logging JSON Objects #208

Closed AmgadHassanNabil closed 1 year ago

AmgadHassanNabil commented 2 years ago

Hi Everyone,

I tried to do a simple logging to the request after using jackson to stringify the request. I keep getting the following errors. It seems to be a similar issue to the link below. https://issues.apache.org/jira/browse/LOG4J2-2949

Appreciate your help as I love this library, and would be great to use it.

Code Sample: String requestBodyText = objectMapper.writeValueAsString(objectMapper.writeValueAsString(requestBody)); logger.log(Level.INFO, requestBodyText, kv("correlationId", correlationId));

Stack trace LogManager error of type FORMAT_FAILURE: Formatting error

java.lang.RuntimeException: java.lang.IllegalArgumentException: can't parse argument number: \"storedProcedureName\":\"INSERT_USER\"
at io.quarkiverse.loggingjson.JsonFormatter.format(JsonFormatter.java:37) 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.ExtHandler.publishToNestedHandlers(ExtHandler.java:97) at io.quarkus.bootstrap.logging.QuarkusDelayedHandler.doPublish(QuarkusDelayedHandler.java:81) at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:66) at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:334) at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:341) at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:341) at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:341) at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:341) at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:341) at org.jboss.logmanager.Logger.logRaw(Logger.java:750) at org.jboss.logmanager.Logger.log(Logger.java:549) at com.ibm.dha.pda.PanoramaDataAccess.StoredProcedure(PanoramaDataAccess.java:40) at com.ibm.dha.pda.PanoramaDataAccess_Subclass.StoredProcedure$$superforward1(Unknown Source) at com.ibm.dha.pda.PanoramaDataAccess_Subclass$$function$$1.apply(Unknown Source) at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54) at io.quarkus.resteasy.runtime.QuarkusRestPathTemplateInterceptor.restMethodInvoke(QuarkusRestPathTemplateInterceptor.java:39) at io.quarkus.resteasy.runtime.QuarkusRestPathTemplateInterceptor_Bean.intercept(Unknown Source) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42) at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:50) at io.quarkus.micrometer.runtime.MicrometerCountedInterceptor.countedMethod(MicrometerCountedInterceptor.java:93) at io.quarkus.micrometer.runtime.MicrometerCountedInterceptor_Bean.intercept(Unknown Source) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42) at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:50) at io.quarkus.micrometer.runtime.MicrometerTimedInterceptor.timedMethod(MicrometerTimedInterceptor.java:78) at io.quarkus.micrometer.runtime.MicrometerTimedInterceptor_Bean.intercept(Unknown Source) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42) at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:50) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42) at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41) at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:33) at com.ibm.dha.pda.PanoramaDataAccess_Subclass.StoredProcedure(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130) at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524) at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474) at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492) at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261) at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161) at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364) at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247) at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:91) at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:564) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29) at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.lang.IllegalArgumentException: can't parse argument number: \"storedProcedureName\":\"INSERT_USER\" at java.base/java.text.MessageFormat.makeFormat(MessageFormat.java:1454) at java.base/java.text.MessageFormat.applyPattern(MessageFormat.java:492) at java.base/java.text.MessageFormat.(MessageFormat.java:371) at java.base/java.text.MessageFormat.format(MessageFormat.java:860) at org.jboss.logmanager.ExtFormatter.formatMessageLegacy(ExtFormatter.java:107) at org.jboss.logmanager.ExtFormatter.formatMessage(ExtFormatter.java:70) at io.quarkiverse.loggingjson.providers.MessageJsonProvider.writeTo(MessageJsonProvider.java:26) at io.quarkiverse.loggingjson.JsonFormatter.format(JsonFormatter.java:26) ... 67 more Caused by: java.lang.NumberFormatException: For input string: "\"storedProcedureName\":\"INSERT_USER\"" at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) at java.base/java.lang.Integer.parseInt(Integer.java:668) at java.base/java.lang.Integer.parseInt(Integer.java:786) at java.base/java.text.MessageFormat.makeFormat(MessageFormat.java:1452) ... 74 more