Re: Getting calling className in Java.Util.Logging.Logger
- From: "henry" <barth.heiko@xxxxxxxxxxxxxx>
- Date: 28 Nov 2006 00:57:19 -0800
Hi,
properly this helps you ....
StackTraceElement[] stack =
Thread.getAllStackTraces().get(Thread.currentThread());
for (int i = 0; i < stack.length; i++) {
StackTraceElement elem = stack[i];
System.out.println("Class "+ elem.getClassName() + " Method" +
elem.getMethodName());
}
I think form here you can go on..
Gugle schrieb:
Hi,
I'm using Java 1.5 and I'm using Java's Logger class for logging. I
would like to know how to get the className and methodname of the
calling method for logging(like log4j does). For e.g., if I'm calling
the log method from method a of class B, then the log message should
contain the classname and method name. I don't want to pass the method
name and class name everytime to the log method. Can someone let me
know how this can be done?
.
- References:
- Prev by Date: Re: Get performance statistics?
- Next by Date: Re: Get performance statistics?
- Previous by thread: Getting calling className in Java.Util.Logging.Logger
- Next by thread: Wrapper classes are Immutable but you use them to make a function parameter a reference?
- Index(es):
Relevant Pages
|
|