on 03-06-2008 11:46 AM
Hi,
I'd like to trace an exceptionstack to a category. How should I do this? If I write "e.printStackTrace" I cannot supply any category.
Should I use "e.getStackTrace()" and log each single line of the array this method delivers?I do not think that this is a good idea.
Thanks for each hint,
Christoph
Hi Christoph,
I am assuming that you have configured categories for Logging in Visual Admin. Once the categories are created in VA do the following in your code:
com.sap.tc.logging.Category appCategory = Category.getCategory(Category.APPLICATIONS, "category_name");
public static final com.sap.tc.logging.Location logger = com.sap.tc.logging.Location.getLocation(YourClass.class);
try
{
//logic here
}
catch(XXXException exe)
{
logger.fatalT(exe.getMessage(),exe.getStackTrace());
}
Hope this will solve your problem.
Regards
Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Solution is simple:
import com.sap.tc.logging.Category;
import com.sap.tc.logging.Location;
class <className> {
private static Category _cat = Category.getCategory(Category.getRoot(), <categoryName>);
private static Location _loc = Location.getLocation(<locationName>);
...
public void myMethod() {
try {
<some code>
catch (Exception e) {
_cat.logThrowableT(Severity.ERROR, _loc, e.getMessage(), e);
}
}
Regards,
Christoph
marked as solved
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I agree throwableT (...) solves your problem but as you said there is no direct method fatalT(String, StackTraceElement[]) but fatalT(String, Object[]) accepts any kind of object. And also if you look at the StackTraceElement, toString() method is overridden with the exception details so when you pass StackTraceElement[] inside the fatalT() obviously it prints the same message.
Regards
Abhilash
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.