logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rubble <mcrubb...@yahoo.com>
Subject extending log4j question
Date Thu, 04 Nov 2004 15:42:53 GMT

I'm trying to migrate over to log4j from a custom
logging framework.  I have a log of log.debug(String,
Object) calls in my code.

What I've tried (and works) is creating singleton that
accesses log4j (i've included my singleton code
below).  I'm concerned that this singleton will
adversely affect performance.  

I saw the post about 
Subject:    RE: extending log4j Logger class? How to?
and would rather not create a MyLogMessage class as it
would mean massive re-coding.  

Will I get a performance bottleneck / hit if I use
this singleton method of extending log4j?  My main
reason for moving to log4j is for performance.  So if
this method performs poorly when compared to the
MyLogMessage class and appender then I'll just

****** sample singleton extending log4j *********
public class Log3 extends org.apache.log4j.Logger {
private static Log3 instance;
private static Logger log4j;

public Log3(String name) {
  log4j = super.getLogger(name);
public static Log3 getLog3(String name) {
  if (instance == null) {
    instance = new Log3(name);
  return instance;
public void debug(Object msg) {

public void debug(String msg, Object obj) {
  log4j.debug(msg + ": " + Util.freeze(obj));


****** using sample singleton  *********
Log3 log = Log3.getLog3(getClass().getName());
log.debug("serialized chartvo: ", chartvo);

thanks in advance,

Lightspoke Free Web Based Database Server

 Free Web-based Database Service 

Do you Yahoo!? 
Check out the new Yahoo! Front Page. 

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

View raw message