on 05-28-2009 6:08 AM
Hi All ,
I am using logging in my webdynpro application
I hv written following java class for logging
***************************************java class Starts *******************************
public class ReferenceApplicationEJBLogger {
private static final Location LOCATION = Location.getLocation("com.apl");
private static final Category CATEGORY = Category.getCategory(Category.APPLICATIONS, "Reference Application");
static{
LOCATION.setMinimumSeverity(CATEGORY, Severity.INFO);
LOCATION.setMaximumSeverity(CATEGORY, Severity.ALL);
CATEGORY.addLog(new FileLog("./log/application/hrhelpdesk/edmProject.%g.trc"));
}
public static void logException (Exception eMessage){
logThrowable(eMessage);
eMessage.printStackTrace();
}
public static void logThrowable (Throwable eMessage){
CATEGORY.logThrowableT(Severity.WARNING, LOCATION, eMessage.getLocalizedMessage(), eMessage);
}
public static void logWarning (String logWarning, Exception eMessage) {
CATEGORY.warningT(LOCATION, logWarning, new Object[]{eMessage});
}
public static void logInfo (String logString){
CATEGORY.infoT(LOCATION, logString);
}
public static void logWarn (String logString){
CATEGORY.warningT(LOCATION, logString);
}
}
***********************************Java class ends here **********************************
and inside my webdynpro applicaiton i have written following code in side catch block
ReferenceApplicationEJBLogger.logInfo("Error occured in application" );
log is getting written in to defined locaiton ./log/application/hrhelpdesk/edmProject.%g.trc
but i also want to print e.printStackTrce() in above mentioned location along with message "Error occured in application".
How to go about it ? Thnx in advance
Regards
Kavita
Let me understand first, are you looking at printing the complete exception log?
catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
System.out.println(sw.toString().toUpperCase());
}
Tested, it works.
Regards,
Nitin
Edited by: Nitin Mahajan on May 28, 2009 9:51 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.