rgoers commented on issue #71:
URL: 
https://github.com/apache/logging-log4j-kotlin/issues/71#issuecomment-2004657515

   @rocketraman I understand your example but I am not sure how it works in 
practice. I have to presume that the Connection class can operate on multiple 
Connection instances. A Logger is a singleton - there will only be one instance 
no matter how many Connection instances you create (to do otherwise would 
create an insane number of Logger instances in the system). We generally 
recommend it be declared as static as to do otherwise means a call is made to 
locate the Logger instance every time a new instance of the class is created. 
What this means is that you can't really have a per-resource context attached 
to a Logger. From inside Log4j we would have no idea which instance of the 
object was used and would not be able to locate the context.
   
   However, you could create an instance of the ScopedContext I proposed and 
attach it to each instance of your Connection and then invoke the logic for 
every method inside of a run method. It should be possible to use AOP to use an 
annotation to cause that to happen automatically.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to