logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Dynamically creating loggers
Date Fri, 15 Apr 2016 15:21:19 GMT
That depends on the environment. You could be getting the Logger from the wrong LoggerContext.

Ralph

> On Apr 15, 2016, at 7:13 AM, Matt Sicker <boards@gmail.com> wrote:
> 
> Couldn't he just cache the LoggerContext and use LoggerContext.getLogger()
> to avoid the ContextSelector lookup?
> 
> On 15 April 2016 at 08:19, Ralph Goers <ralph.goers@dslextreme.com> wrote:
> 
>> The logging implementation stores the logger in a map.  However, when you
>> call getLogger ClassLoaderContextSelector will have to locate the
>> ClassLoader for the class loading the Logger. This can be fairly expensive.
>> If you are using a different ContextSelector it might work better. Or you
>> can create a Map of the Loggers yourself.
>> 
>> Ralph
>> 
>>> On Apr 15, 2016, at 2:02 AM, Jochen Wiedmann <jochen.wiedmann@gmail.com>
>> wrote:
>>> 
>>> Hi,
>>> 
>>> I've got an application, where I would like to obtain loggers on the
>>> fly, because the logger name isn't known in advance. (Think of it as a
>>> logging server, which will be used by remote clients.)
>>> 
>>> Now, creating a Logger might be an expensive operation. Thus, my
>> question:
>>> 
>>> - Would you recommend to always invoke LogManager.getLogger(String)
>>> and use the result?
>>> - Or would it be better to maintain a Map<String,Logger> with the
>>> logger name as key?
>>> 
>>> Thanks,
>>> 
>>> Jochen
>>> 
>>> --
>>> The next time you hear: "Don't reinvent the wheel!"
>>> 
>>> 
>> http://www.keystonedevelopment.co.uk/wp-content/uploads/2014/10/evolution-of-the-wheel-300x85.jpg
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>> 
>>> 
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 
>> 
> 
> 
> -- 
> Matt Sicker <boards@gmail.com>



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message