[
https://issues.apache.org/jira/browse/HTTPCLIENT-2096?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17150444#comment-17150444
]
Oleg Kalnichevski commented on HTTPCLIENT-2096:
-----------------------------------------------
[~ckozak] This is not something I would consider a major surprise. The cost of
setting up those four loggers is likely still negligible compared to the
overall overhead of connection initialization. What is important that there
should be new loggers created during each message exchange. That would be
prohibitively costly.
Oleg
> 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
>
> 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]