[ 
https://issues.apache.org/jira/browse/LOG4J2-3017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17283085#comment-17283085
 ] 

Ralph Goers edited comment on LOG4J2-3017 at 2/11/21, 3:40 PM:
---------------------------------------------------------------

Yes, Logback (SLF4J) only allows String values so the value will be converted 
to a String when passed to those APIs. In the case of Log4j 2 it has a method 
that accepts an Object, which is what a GString is to Java. That gets turned 
into an ObjectMessage that then later within Log4j 2 will most likely be 
converted to a String when it is processed by an Appender. I suspect that if 
you call the toString() method on the GString on the logging call that the 
problem would go away since one of Log4j's String methods would be used instead.

Log4j 1.2 only accepts Objects in its API but when they are first accessed they 
are converted to a String either by a cast or by calling toString(). So I would 
expect this would have the same behavior as SLF4J. 


was (Author: [email protected]):
Yes, Logback and Log4j 1.2 only allow String values so the value will be 
converted to a String when passed to those APIs. In the case of Log4j 2 it has 
a method that accepts an Object, which is what a GString is to Java. That gets 
turned into an ObjectMessage that then later within Log4j 2 will most likely be 
converted to a String when it is processed by an Appender. I suspect that if 
you call the toString() method on the GString on the logging call that the 
problem would go away since one of Log4j's String methods would be used instead.

> Groovy logging of GString with $ notation is very slow
> ------------------------------------------------------
>
>                 Key: LOG4J2-3017
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3017
>             Project: Log4j 2
>          Issue Type: Improvement
>            Reporter: Liviu Carausu
>            Assignee: Volkan Yazici
>            Priority: Major
>         Attachments: SomeClass.groovy, TestLogging.groovy
>
>
>  
> Logging of GString is very slow.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to