I would like to clarify the first paragraph further.
Legacy Code: (cannot be modified)
...
OurLogger.log(new LogObject("com.myclass", level.DEBUG, "Log Message
1"));
OurLogger Class: (can be modified)
public static void log(LogObject logObject) {
// refactor to use concurrent hashmap to store
and lookup Log4j Loggers
// log the request through Log4j Logger
}
Hope this helps.
Faheem
-----Original Message-----
From: Zakaria, Faheem
Sent: Friday, March 09, 2007 9:38 AM
To: Log4J Users List
Subject: RE: Using LogManager.getLogger(String)
Hey Curt,
Thank you for getting back to me.
Currently, legacy code uses a static method access logging
functionality. Furthermore, the methods signature accepts an Object
populated with class name, level, etc. We cannot modify the legacy code
and have thus decided to migrate the static method
OurLogger.log(LogObject) to Log4j, under the covers.
Therefore, to emulate the 'final static Logger logger =
Logger.getLogger(class)' paradigm, our plan is to use a Concurrent
hashMap to store the (class name, Log4j Logger) key-value pair. On
subsequent log invocations, the hashmap would be used to lookup the map
and use it for the logging request. The map would reside within our
OurLogger Class.
Could you elaborate on why LogManager.getLogger().info() is not
advisable?
Thanks for your reply.
Faheem
-----Original Message-----
From: Curt Arnold [mailto:[EMAIL PROTECTED]
Sent: Friday, March 09, 2007 2:39 AM
To: Log4J Users List
Subject: Re: Using LogManager.getLogger(String)
On Mar 8, 2007, at 4:26 PM, Zakaria, Faheem wrote:
> Since this is a legacy system, our
> plan is to lookup the Log4j Logger on every log request through
> LogManager.getLogger(String).
Could you explain your reasoning here. Maybe give some examples of
the existing logging calls in your code and why you think you should
repeatedly call getLogger.
>
>
> 1. Is it okay to use LogManager in this manner?
Yes, but not advisable.
> 2. Are there any performance issues with this approach?
Likely substantial.
> 3. Are there any scalability concerns with this approach?
Possibly.
> 4. Will reloading the log4j.xml configuration work with this approach?
Shouldn't introduce any new problems.
> 5. Instead of using the LogManager, does it make sense to use a static
> ConcurrentHashMap to store ("logger name",Logger) key value pairs and
> perform a local Logger lookup on every log request?
Duplicates what should be going on in LogManager, might be more
efficient depending on the implementation of LogManager.
> 6. What would you recommend?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]