You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by rubble <mc...@yahoo.com> on 2004/11/04 16:42:53 UTC

extending log4j question

Hello,

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
re-code.


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

public Log3(String name) {
  super(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) {
  log4j.debug(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,
matthew

---
Lightspoke Free Web Based Database Server
http://www.lightspoke.com



=====
 Free Web-based Database Service 


		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


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


Re: extending log4j question

Posted by rubble <mc...@yahoo.com>.
freeze simple method that serializes any object to
xml.  
I have a bunch of 

.debug("could do do this to this record", RecordVO);

I know, I could convert my code to
.debug("could do do this to this record" +
Util.freeze(RecordVO) );

But since I was using my own logging framework before
I just made it a convenience method.  

But I'm also asking the question in a more general
sense... For instance, if I wanted the code update the
status on a big brother monitor, or something totally
custom like that.  Hmmm... but I suppose you would
write a custom appender to do that then?
  
So are you saying my singleton poses a performance
problem and I should just do this: 
.debug("could do do this to this record" +
Util.freeze(RecordVO) );
?

Thanks a bunch!

-matt  


--- Ceki G�lc� <ce...@qos.ch> wrote:

> At 04:42 PM 11/4/2004, rubble wrote:
> 
> >public void debug(String msg, Object obj) {
> >   log4j.debug(msg + ": " + Util.freeze(obj));
> >}
> 
> What does Util.freeze(obj) do?
> 
> -- 
> Ceki G�lc�
> 
>       For log4j documentation consider "The complete
> log4j manual"
>       http://www.qos.ch/shop/products/eclm/  
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
> 


=====
 Free Web-based Database Service 


		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


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


Re: extending log4j question

Posted by Ceki Gülcü <ce...@qos.ch>.
At 04:42 PM 11/4/2004, rubble wrote:

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

What does Util.freeze(obj) do?

-- 
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      http://www.qos.ch/shop/products/eclm/  



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