0

I have one query regarding logging is that for loging in my application I am using apache log4j api and I am able to log events of my application in a seprate log file , The query is that in my application let say inside catch block I normally write e.printstacktrace() which is not proper way since I want to also log my error in the custom log file and not on console , so for this inside the catch block what should I write to log the messages back to the custom log file.. please advise

catch (Exception e) {
 log.logError("Error getting  value.", e);
      }

and also please suggest how to log other messages like warning and alert one also..!!

Crazy4Java
  • 269
  • 2
  • 6
  • 13
  • I also found the answers at this link http://stackoverflow.com/questions/4347797/how-to-send-a-stacktrace-to-log4j – Crazy4Java Aug 20 '12 at 17:11

1 Answers1

2
log.error("Error getting value. " + e.getLocalizedMessage());
maba
  • 47,113
  • 10
  • 108
  • 118