logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Stauffer" <stauffer.ja...@gmail.com>
Subject Re: Loggers and Inheritance
Date Tue, 06 Jun 2006 17:21:45 GMT
1. The super-class logger: SuperClazz
2. Define the loggers as follows:
private Logger log=Logger.getLogger(getClass());

On 6/6/06, Konstantinos Karadamoglou <kkarad@googlemail.com> wrote:
> Hello all,
>
> I have two questions about Loggers and Inheritance. Lets assume that we have
> following class inheritance:
>
> public class SuperClazz{
>   private Logger log=Logger.getLogger(SuperClazz.class);
>
>   private void method1(){
>      log.info("method1 invoked");
>   }
>
> }
> //------------------------
> public class ChildClazz1 extends SuperClazz{
>   private Logger log=Logger.getLogger(ChildClazz1.class);
>
>   private void method2(){
>      log.info("method2 invoked");
>   }
>
> }
> //------------------------
> public class ChildClazz2 extends SuperClazz{
>   private Logger log=Logger.getLogger(ChildClazz2.class);
>
>   private void method3(){
>      log.info("method3 invoked");
>   }
>
> }
>
> 1) if method1 is invoked (somehow) which Logger is used and what the logger
> display name will be at the console?
>
> 2) How can I enforce method1 to use the logger of the child method?
>
> Thank you in advance, Kostas
>
>


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

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


Mime
View raw message