954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to print error with line number in using Log4j

Hi Folks,
I have to print the error with line and error name using log4j property file so what property should i put in log4j property file so i will print error with line numbers!


Regards,
Rajeshwar.

rajeshwarreddyt
Newbie Poster
8 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

Most of the log calls allow you to print a message and the caught exception. Try this:

try
{
  // do something
} catch ( Exception e )
{
  if ( log.isDebugEnabled() )
  {
    log.debug( "Exception throw.", e );
  }
}

This will log the message and the stack trace (including line numbers) for the caught exception. There are similar methods for info, warn and error.

darkagn
Veteran Poster
1,197 posts since Aug 2007
Reputation Points: 404
Solved Threads: 200
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You