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 Ian Huynh <ia...@hubspan.com> on 2004/01/30 02:28:30 UTC

extending log4j Logger class? How to?

I would like to debug more than just a string so would it make sense to extend the Log4J Logger?

eg.  let say, i'd like to have the following interface
    
         Logger.debug( String, byte[], Document, Throwable)

I can certainly use a wrapper pattern (see below) but would have to make massive changes to my code.  

public class MyLogger {
   public MyLogger (Logger log4jLogger) {}
}
   
So the alternative is,  I tried to extend the Logger Class but is unsure how to get the LoggerFactory to return MyLogger instead of Logger class.

Is there an easier way to accomplish this ?

Thanks.



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


Re: extending log4j Logger class? How to?

Posted by Donald Larmee | ALTERthought <dl...@alterthought.com>.
if you can pack all of the data you would like to log into one wrapper 
object, I would look into using an ObjectRenderer to do what you suggest. i.e.,

    logger.debug(new MyLogObject(String,byte[], Document), Throwable);

You would then provide an ObjectRenderer that undertands how to handle a 
MyLogObject...etc...

-d


At 08:28 PM 1/29/2004, you wrote:

>I would like to debug more than just a string so would it make sense to 
>extend the Log4J Logger?
>
>eg.  let say, i'd like to have the following interface
>
>          Logger.debug( String, byte[], Document, Throwable)
>
>I can certainly use a wrapper pattern (see below) but would have to make 
>massive changes to my code.
>
>public class MyLogger {
>    public MyLogger (Logger log4jLogger) {}
>}
>
>So the alternative is,  I tried to extend the Logger Class but is unsure 
>how to get the LoggerFactory to return MyLogger instead of Logger class.
>
>Is there an easier way to accomplish this ?
>
>Thanks.
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org


_______________________________________

   Donald H. Larmee
   ALTERthought, Inc.
   804.301.8867 (c)

   www.alterthought.com
_______________________________________ 



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