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 "Mathew, Bindhu" <Bi...@ssa.gov> on 2001/12/13 19:13:52 UTC

name of method that throws exception

 Hi there,

 I am calling Logger in the catch block of try-catch method in my java
program and whenever an exception comes it writes to the log file. Is there
any way to get the name of the method that throws an exception in the log
file?? At present I am getting the thread (%t) and the class (logger.class -
%c) in the output log message.

Please give me the link, if someone has already asked this.
thanks,
bmathew
 
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: name of method that throws exception

Posted by Thomas Tuft Muller <tt...@online.no>.
You get the stacktrace by calling the overloaded logging method with the
exception as the second parameter

e.g.

try {
	doSomething();
} catch( Exception e ) {
	log.error( "Error running doSomething() [" + e.getMessage() + "]", e );
}

Hope this helps.

--

Thomas



| -----Original Message-----
| From: Mathew, Bindhu [mailto:Bindhu.Mathew@ssa.gov]
| Sent: 13 December 2001 18:14
| To: 'log4j-user@jakarta.apache.org'
| Subject: name of method that throws exception
|
|
|  Hi there,
|
|  I am calling Logger in the catch block of try-catch method in my java
| program and whenever an exception comes it writes to the log
| file. Is there
| any way to get the name of the method that throws an exception in the log
| file?? At present I am getting the thread (%t) and the class
| (logger.class -
| %c) in the output log message.
|
| Please give me the link, if someone has already asked this.
| thanks,
| bmathew
|
|
|
| --
| To unsubscribe, e-mail:
| <ma...@jakarta.apache.org>
| For additional commands, e-mail:
| <ma...@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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>