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

ASF subversion and git services commented on HTTPCLIENT-2096:
-------------------------------------------------------------

Commit 986686535750a6a665a206ba0cc892d8fb24bbec in httpcomponents-client's 
branch refs/heads/5.1.x from Carter Kozak
[ https://gitbox.apache.org/repos/asf?p=httpcomponents-client.git;h=9866865 ]

HTTPCLIENT-2096: Migrate instance loggers to static fields

Note that this may change the origin of logging when classes
have been subclassed, as the logger origin will use the class
name that defined the logger where previously the subclass type
would be used. In scenarios where external libraries subclass
httpclient utilities this allows httpclient logging to maintain
the `org.apache.hc` prefix instead of inheriting arbitrary
subclass names.

Using some logging frameworks this may result in reduced churn
when httpclient components are created (new connections, for example)
because loggers are looked up once per class.


> Consider using static loggers instead of instance loggers
> ---------------------------------------------------------
>
>                 Key: HTTPCLIENT-2096
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2096
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 5.0.1
>            Reporter: Carter Kozak
>            Priority: Major
>          Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> I'd like to consider replacing instance loggers with static loggers to avoid 
> paying a penalty on instantiation. This would result in slightly different 
> (and arguably better) behavior when classes are extended, as the logger 
> origin would reflect the location that produced logging, not the subclass 
> that happened to extend it. For example, if I want to debug hc5, I might set 
> the {{org.apache.hc}} origin to {{TRACE}} level and add it to a separate 
> appender. If I've extended a component it won't appear with my httpclient 
> logs using the {{getClass()}} approach.
> From [~olegk]
> bq. As far as I know static loggers in low level libraries are considered 
> evil and are to be avoided in favor of instance loggers. The overhead of 
> logger instantiation is quite manageable if one injects logger through a 
> constructor of frequently allocated and deallocated components.
> Conversation started here:
> https://github.com/apache/httpcomponents-client/pull/232#discussion_r448963006
> Some existing documentation:
> http://www.slf4j.org/faq.html#declared_static
> https://logging.apache.org/log4j/2.x/manual/usage.html#StaticVsNonStatic



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to