Re: Getting class name without instance?
From: Chris (chris2k01_at_hotmail.com)
Date: 11/29/03
- Next message: T.Venkatesh: "Would like to calculate Standard Deviation,Variance of more than 1 column in table and Display it in JSP"
- Previous message: gg: "Re: What's the Big Java Development Environment These Days?"
- In reply to: Sibyl: "Getting class name without instance?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 Nov 2003 07:49:25 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Sibyl wrote:
[snip]
> import org.apache.log4j.Logger;
>
> public class Foo {
> ...
>
> private static Logger logger = Logger.getLogger([get either Class
> object or class name here--the result should be the Class Foo.class
> or its fully qualified name as a String]);
> }
>
> ------------
> The point is that this same statement needs to be in every class
> where logging is done, and I would like them all to be identical.
[snip]
Hi,
How about:
java.lang.Class c = Foo.class;
and do whatever you need with the Class object, like getName().
- --
Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/x98JwxczzJRavJYRAqkOAJ9Lv9qhdkR5ZuSMbDamBcvgLjqIpwCgwsRn
0A0fipDLig1JjhktjKWsReE=
=zLFy
-----END PGP SIGNATURE-----
- Next message: T.Venkatesh: "Would like to calculate Standard Deviation,Variance of more than 1 column in table and Display it in JSP"
- Previous message: gg: "Re: What's the Big Java Development Environment These Days?"
- In reply to: Sibyl: "Getting class name without instance?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|