logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From steve.be...@xks.co.uk
Subject Re: Log based on object and not the class
Date Thu, 11 Dec 2003 15:46:46 GMT

Scott,

Why not add a switch parameter to the parent method?

i.e

Class Parent {
             ...
             Public void myMethod(boolean b) {
                         if (b==true) {
                              Logger.debug("logging message");
                         }
             }
}

Class Child1 extends Parent {
             ...
             Public void execute1() {
                         this.myMethod(true);
             }
}

Class Child2 extends Parent {
             ...
             Public void execute2() {
                         this.myMethod(false);
             }
}

Steve




                                                                                         
                                             
                      "Scott Melcher"                                                    
                                             
                      <smelcher@assistc        To:       "'Log4J Users List'" <log4j-user@jakarta.apache.org>
                         
                      orp.com>                 cc:                                    
                                                
                                               Subject:  Log based on object and not the class
                                        
                      11/12/2003 15:46                                                   
                                             
                      Please respond to                                                  
                                             
                      "Log4J Users                                                       
                                             
                      List"                                                              
                                             
                                                                                         
                                             
                                                                                         
                                             




Hi, my problem is that in my object architecture/hierarchy I have dozens of
classes that extend a single parent class.  The parent class has a method
that is called by all of the child classes.  It is in this method that I
have several log statements.  The problem is that I only have the ability
to
turn the logger on or off for that parent class.  If I turn it on then I
will get too many logging messages.  I would only like to log messages in
that parent class for a given child class.
I know I am not explaing this well so I will add a quick code example.

In my example I only want to log messages from the Child1 class.  Therefore
if I was to execute my two child classes I would want to get a single
"logging message".

Class Parent {
             ...
             Public void myMethod() {
                         Logger.debug("logging message");
             }
}

Class Child1 extends Parent {
             ...
             Public void execute1() {
                         this.myMethod();
             }
}

Class Child2 extends Parent {
             ...
             Public void execute2() {
                         this.myMethod();
             }
}

THANKS for any input you can give!



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







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


Mime
View raw message