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 Stephen Levinson <St...@sun.com> on 2001/09/17 22:01:51 UTC

Categories for Inner Classes

Hi all...

	In setting categories for classes I am using a STATIC instance of
Category ... sending in the class name.

	If I have an inner class I'd like to be able to set a category with
ITS OWN NAME... but I can't use a STATIC in the inner class.

	Is there any way to have the category for an inner class have its
own name?

Thanks in Advance, Stephen

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


RE: Categories for Inner Classes

Posted by Thomas Tuft Muller <tt...@online.no>.
Exactly what I recommended in a reply to the original posting a couple of
days ago.

--

Thomas


| -----Original Message-----
| From: Craig Newlander [mailto:cnewlander@eqtc.com]
| Sent: 20 September 2001 17:52
| To: LOG4J Users Mailing List; ttm@online.no
| Subject: RE: Categories for Inner Classes
|
|
| then define it as a static member of the class (not the inner class)
| and the inner class will be able to reference it.
|
|
| -----Original Message-----
| From: Thomas Tuft Muller [mailto:ttm@online.no]
| Sent: Thursday, September 20, 2001 11:40 AM
| To: LOG4J Users Mailing List
| Subject: RE: Categories for Inner Classes
|
|
| 'final' only enforces that the reference can't be reassigned -
| it's still an
| instance variable if it's declared non-static, thus the 4 bytes per object
| waste still applies.
|
| --
|
| Thomas
|
|
| | -----Original Message-----
| | From: Craig Newlander [mailto:cnewlander@eqtc.com]
| | Sent: 20 September 2001 17:34
| | To: LOG4J Users Mailing List; ttm@online.no
| | Subject: RE: Categories for Inner Classes
| |
| |
| | use final
| |
| | -----Original Message-----
| | From: Thomas Tuft Muller [mailto:ttm@online.no]
| | Sent: Thursday, September 20, 2001 11:28 AM
| | To: LOG4J Users Mailing List
| | Subject: RE: Categories for Inner Classes
| |
| |
| | True, but you will waste 4 bytes in every object just to
| | reference the same
| | Category. That's essentially why you want to use a static
| | reference so every
| | instance can share the same reference.
| |
| | --
| |
| | Thomas
| |
| |
| | | -----Original Message-----
| | | From: Craig Newlander [mailto:cnewlander@eqtc.com]
| | | Sent: 20 September 2001 17:28
| | | To: LOG4J Users Mailing List; herve.agnoux@diaam-informatique.com
| | | Subject: RE: Categories for Inner Classes
| | |
| | |
| | | so don't use static - all object will reference the same
| instance of the
| | | Category anyways.
| | |
| | | -----Original Message-----
| | | From: Herve AGNOUX [mailto:herve.agnoux@diaam-informatique.com]
| | | Sent: Wednesday, September 19, 2001 2:47 AM
| | | To: LOG4J Users Mailing List
| | | Subject: Re: Categories for Inner Classes
| | |
| | |
| | | Le 17 Sep 01, Stephen Levinson a écrit :
| | |
| | | >
| | | >  If I have an inner class I'd like to be able to set a category with
| | | > ITS OWN NAME... but I can't use a STATIC in the inner class.
| | | >
| | |
| | | I use log4j.category.com.xx.zz.Clazz$Inner=INFO
| | |
| | | '$' is the separator between class and inner.
| | |
| | |
| | | --
| | | Sur le Web, tout de suite.
| | | Herve AGNOUX - diaam informatique
| | | http://www.diaam-informatique.com
| | |
| | | ---------------------------------------------------------------------
| | | 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
| | |
| | |
| |
| |
| |
| |
| *************************************************************************
| | Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights
| reserved.
| | Confidential. No liability whatsoever is accepted for any loss or damage
| | suffered as a result of accessing this message or any attachments.
| |
| | ---------------------------------------------------------------------
| | 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
| |
| |
|
|
|
| *************************************************************************
| Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved.
| Confidential. No liability whatsoever is accepted for any loss or damage
| suffered as a result of accessing this message or any attachments.
|
| ---------------------------------------------------------------------
| 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
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved. 
Confidential. No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

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


RE: Categories for Inner Classes

Posted by Craig Newlander <cn...@eqtc.com>.
then define it as a static member of the class (not the inner class)
and the inner class will be able to reference it.


-----Original Message-----
From: Thomas Tuft Muller [mailto:ttm@online.no]
Sent: Thursday, September 20, 2001 11:40 AM
To: LOG4J Users Mailing List
Subject: RE: Categories for Inner Classes


'final' only enforces that the reference can't be reassigned - it's still an
instance variable if it's declared non-static, thus the 4 bytes per object
waste still applies.

--

Thomas


| -----Original Message-----
| From: Craig Newlander [mailto:cnewlander@eqtc.com]
| Sent: 20 September 2001 17:34
| To: LOG4J Users Mailing List; ttm@online.no
| Subject: RE: Categories for Inner Classes
|
|
| use final
|
| -----Original Message-----
| From: Thomas Tuft Muller [mailto:ttm@online.no]
| Sent: Thursday, September 20, 2001 11:28 AM
| To: LOG4J Users Mailing List
| Subject: RE: Categories for Inner Classes
|
|
| True, but you will waste 4 bytes in every object just to
| reference the same
| Category. That's essentially why you want to use a static
| reference so every
| instance can share the same reference.
|
| --
|
| Thomas
|
|
| | -----Original Message-----
| | From: Craig Newlander [mailto:cnewlander@eqtc.com]
| | Sent: 20 September 2001 17:28
| | To: LOG4J Users Mailing List; herve.agnoux@diaam-informatique.com
| | Subject: RE: Categories for Inner Classes
| |
| |
| | so don't use static - all object will reference the same instance of the
| | Category anyways.
| |
| | -----Original Message-----
| | From: Herve AGNOUX [mailto:herve.agnoux@diaam-informatique.com]
| | Sent: Wednesday, September 19, 2001 2:47 AM
| | To: LOG4J Users Mailing List
| | Subject: Re: Categories for Inner Classes
| |
| |
| | Le 17 Sep 01, Stephen Levinson a écrit :
| |
| | >
| | >  If I have an inner class I'd like to be able to set a category with
| | > ITS OWN NAME... but I can't use a STATIC in the inner class.
| | >
| |
| | I use log4j.category.com.xx.zz.Clazz$Inner=INFO
| |
| | '$' is the separator between class and inner.
| |
| |
| | --
| | Sur le Web, tout de suite.
| | Herve AGNOUX - diaam informatique
| | http://www.diaam-informatique.com
| |
| | ---------------------------------------------------------------------
| | 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
| |
| |
|
|
|
| *************************************************************************
| Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved.
| Confidential. No liability whatsoever is accepted for any loss or damage
| suffered as a result of accessing this message or any attachments.
|
| ---------------------------------------------------------------------
| 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
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved.
Confidential. No liability whatsoever is accepted for any loss or damage
suffered as a result of accessing this message or any attachments.

---------------------------------------------------------------------
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


RE: Categories for Inner Classes

Posted by Thomas Tuft Muller <tt...@online.no>.
'final' only enforces that the reference can't be reassigned - it's still an
instance variable if it's declared non-static, thus the 4 bytes per object
waste still applies.

--

Thomas


| -----Original Message-----
| From: Craig Newlander [mailto:cnewlander@eqtc.com]
| Sent: 20 September 2001 17:34
| To: LOG4J Users Mailing List; ttm@online.no
| Subject: RE: Categories for Inner Classes
|
|
| use final
|
| -----Original Message-----
| From: Thomas Tuft Muller [mailto:ttm@online.no]
| Sent: Thursday, September 20, 2001 11:28 AM
| To: LOG4J Users Mailing List
| Subject: RE: Categories for Inner Classes
|
|
| True, but you will waste 4 bytes in every object just to
| reference the same
| Category. That's essentially why you want to use a static
| reference so every
| instance can share the same reference.
|
| --
|
| Thomas
|
|
| | -----Original Message-----
| | From: Craig Newlander [mailto:cnewlander@eqtc.com]
| | Sent: 20 September 2001 17:28
| | To: LOG4J Users Mailing List; herve.agnoux@diaam-informatique.com
| | Subject: RE: Categories for Inner Classes
| |
| |
| | so don't use static - all object will reference the same instance of the
| | Category anyways.
| |
| | -----Original Message-----
| | From: Herve AGNOUX [mailto:herve.agnoux@diaam-informatique.com]
| | Sent: Wednesday, September 19, 2001 2:47 AM
| | To: LOG4J Users Mailing List
| | Subject: Re: Categories for Inner Classes
| |
| |
| | Le 17 Sep 01, Stephen Levinson a écrit :
| |
| | >
| | >  If I have an inner class I'd like to be able to set a category with
| | > ITS OWN NAME... but I can't use a STATIC in the inner class.
| | >
| |
| | I use log4j.category.com.xx.zz.Clazz$Inner=INFO
| |
| | '$' is the separator between class and inner.
| |
| |
| | --
| | Sur le Web, tout de suite.
| | Herve AGNOUX - diaam informatique
| | http://www.diaam-informatique.com
| |
| | ---------------------------------------------------------------------
| | 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
| |
| |
|
|
|
| *************************************************************************
| Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved.
| Confidential. No liability whatsoever is accepted for any loss or damage
| suffered as a result of accessing this message or any attachments.
|
| ---------------------------------------------------------------------
| 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
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved. 
Confidential. No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

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


RE: Categories for Inner Classes

Posted by Craig Newlander <cn...@eqtc.com>.
use final

-----Original Message-----
From: Thomas Tuft Muller [mailto:ttm@online.no]
Sent: Thursday, September 20, 2001 11:28 AM
To: LOG4J Users Mailing List
Subject: RE: Categories for Inner Classes


True, but you will waste 4 bytes in every object just to reference the same
Category. That's essentially why you want to use a static reference so every
instance can share the same reference.

--

Thomas


| -----Original Message-----
| From: Craig Newlander [mailto:cnewlander@eqtc.com]
| Sent: 20 September 2001 17:28
| To: LOG4J Users Mailing List; herve.agnoux@diaam-informatique.com
| Subject: RE: Categories for Inner Classes
|
|
| so don't use static - all object will reference the same instance of the
| Category anyways.
|
| -----Original Message-----
| From: Herve AGNOUX [mailto:herve.agnoux@diaam-informatique.com]
| Sent: Wednesday, September 19, 2001 2:47 AM
| To: LOG4J Users Mailing List
| Subject: Re: Categories for Inner Classes
|
|
| Le 17 Sep 01, Stephen Levinson a écrit :
|
| >
| >  If I have an inner class I'd like to be able to set a category with
| > ITS OWN NAME... but I can't use a STATIC in the inner class.
| >
|
| I use log4j.category.com.xx.zz.Clazz$Inner=INFO
|
| '$' is the separator between class and inner.
|
|
| --
| Sur le Web, tout de suite.
| Herve AGNOUX - diaam informatique
| http://www.diaam-informatique.com
|
| ---------------------------------------------------------------------
| 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
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved.
Confidential. No liability whatsoever is accepted for any loss or damage
suffered as a result of accessing this message or any attachments.

---------------------------------------------------------------------
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


RE: Categories for Inner Classes

Posted by Thomas Tuft Muller <tt...@online.no>.
True, but you will waste 4 bytes in every object just to reference the same
Category. That's essentially why you want to use a static reference so every
instance can share the same reference.

--

Thomas


| -----Original Message-----
| From: Craig Newlander [mailto:cnewlander@eqtc.com]
| Sent: 20 September 2001 17:28
| To: LOG4J Users Mailing List; herve.agnoux@diaam-informatique.com
| Subject: RE: Categories for Inner Classes
|
|
| so don't use static - all object will reference the same instance of the
| Category anyways.
|
| -----Original Message-----
| From: Herve AGNOUX [mailto:herve.agnoux@diaam-informatique.com]
| Sent: Wednesday, September 19, 2001 2:47 AM
| To: LOG4J Users Mailing List
| Subject: Re: Categories for Inner Classes
|
|
| Le 17 Sep 01, Stephen Levinson a écrit :
|
| >
| >  If I have an inner class I'd like to be able to set a category with
| > ITS OWN NAME... but I can't use a STATIC in the inner class.
| >
|
| I use log4j.category.com.xx.zz.Clazz$Inner=INFO
|
| '$' is the separator between class and inner.
|
|
| --
| Sur le Web, tout de suite.
| Herve AGNOUX - diaam informatique
| http://www.diaam-informatique.com
|
| ---------------------------------------------------------------------
| 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
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved. 
Confidential. No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

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


RE: Categories for Inner Classes

Posted by Craig Newlander <cn...@eqtc.com>.
so don't use static - all object will reference the same instance of the
Category anyways.

-----Original Message-----
From: Herve AGNOUX [mailto:herve.agnoux@diaam-informatique.com]
Sent: Wednesday, September 19, 2001 2:47 AM
To: LOG4J Users Mailing List
Subject: Re: Categories for Inner Classes


Le 17 Sep 01, Stephen Levinson a écrit :

>
>  If I have an inner class I'd like to be able to set a category with
> ITS OWN NAME... but I can't use a STATIC in the inner class.
>

I use log4j.category.com.xx.zz.Clazz$Inner=INFO

'$' is the separator between class and inner.


--
Sur le Web, tout de suite.
Herve AGNOUX - diaam informatique
http://www.diaam-informatique.com

---------------------------------------------------------------------
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


Re: Categories for Inner Classes

Posted by Herve AGNOUX <he...@diaam-informatique.com>.
Le 17 Sep 01, Stephen Levinson a écrit :

> 
>  If I have an inner class I'd like to be able to set a category with
> ITS OWN NAME... but I can't use a STATIC in the inner class.
> 

I use log4j.category.com.xx.zz.Clazz$Inner=INFO

'$' is the separator between class and inner.


--
Sur le Web, tout de suite.
Herve AGNOUX - diaam informatique
http://www.diaam-informatique.com

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


RE: Categories for Inner Classes

Posted by Craig Newlander <cn...@eqtc.com>.
I ran into the same scenario,  The Catergoy Object is a factory so all
"instances" of Category using the same
foo.class will reference the same instance anyways.   Can you give the inner
class a name?


-----Original Message-----
From: Stephen Levinson [mailto:Stephen.Levinson@sun.com]
Sent: Monday, September 17, 2001 3:02 PM
To: 'LOG4J Users Mailing List'
Subject: Categories for Inner Classes


Hi all...

	In setting categories for classes I am using a STATIC instance of
Category ... sending in the class name.

	If I have an inner class I'd like to be able to set a category with
ITS OWN NAME... but I can't use a STATIC in the inner class.

	Is there any way to have the category for an inner class have its
own name?

Thanks in Advance, Stephen

---------------------------------------------------------------------
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


RE: Categories for Inner Classes

Posted by Thomas Tuft Muller <tt...@online.no>.
Define the Category reference for the inner class in the outer class as
well. The inner class has seamlessly access to it.

class Foo {
	private static final Category fooLog =
		 Category.getInstance( Foo.class.getName() );

	private static final Category barLog =
		 Category.getInstance( Bar.class.getName() );

	static class Bar {

		void barMethod() {
			barLog.debug( "I am bar" );
		}

	}

}

Hope this helps

--

Thomas



| -----Original Message-----
| From: Stephen Levinson [mailto:Stephen.Levinson@sun.com]
| Sent: 17 September 2001 21:02
| To: 'LOG4J Users Mailing List'
| Subject: Categories for Inner Classes
|
|
| Hi all...
|
| 	In setting categories for classes I am using a STATIC instance of
| Category ... sending in the class name.
|
| 	If I have an inner class I'd like to be able to set a category with
| ITS OWN NAME... but I can't use a STATIC in the inner class.
|
| 	Is there any way to have the category for an inner class have its
| own name?
|
| Thanks in Advance, Stephen
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
| For additional commands, e-mail: log4j-user-help@jakarta.apache.org
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved. 
Confidential. No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

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