A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
this week in the
Other Open Source APIs
How to get java class name and method name and print it from the method
Joined: Apr 27, 2006
Nov 01, 2007 01:58:00
Im using custom logger (simple prints)
And I like to print the class name and the method from witch the log print has bean executed.
How can I do it ?
I can't use log4j in my project .
Joined: Mar 22, 2005
Nov 01, 2007 02:18:00
"new Exception().getStackTrace()" gives you the stack trace information which contains the class and method name.
Jesper de Jong
Joined: Aug 16, 2005
Nov 01, 2007 02:24:00
You can't use Log4J, but since Log4J is open source you could still have a look at the source code of Log4J to see how it's done there.
Java Beginners FAQ
JavaRanch SCJP FAQ
The Java Tutorial
Java SE 8 API documentation
Joined: Feb 05, 2003
Nov 01, 2007 07:38:00
thread recently discussed the same subject.
I agree. Here's the link:
subject: How to get java class name and method name and print it from the method
Print calling method and class name
Printing number of records from a ResultSet
Printing method name using log4j
how does java implement all this ?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015