I'm trying to do some automatic parsing of java exceptions and stacktraces being sent to our central server (written in c#). I have an algorithm working now which parses the stacktraces to a standard representation and in the process attempt to determine the locale which generated the exception, but have only tested on english and would like to validate for other locales as well.
More specifically each line in the stacktrace seems to be formatted roughly like this:
...
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
...
where the 'at' seems to be locale specific and the rest is pretty generic for formatting. I'm looking for an easy way of obtaining these locale specific separator words that does not require me switching regional settings to all possible languages I can think of.
I'm no java wiz, so I was wondering if I could locate/download some resources that specify the separator words from different locales or if there are other obvious approaches to make my life easier (at least for this little task)?
UPDATE: Just to be clear, I have no real problem in parsing the line to get the methodname/classname and the filename/linenumber if they are available. What I am looking for is the list of starting words, where 'at' is the english one (as displayed above). I'm thinking that these strings may appear in a 'language pack' or a resource file somewhere, but not being a java person I don't really know where to look.
ANOTHER UPDATE: Tried the following code which seems to indicate that the 'at' word is the same for all locales (if the Locale.setLocale-method is the correct call)
public static void main(String[] args) {
Locale[] locs = Locale.getAvailableLocales();
for(Locale l:locs)
{
System.out.println(l.getDisplayName());
Locale.setDefault(l);
GetAndPrintException();
}
}
private static void GetAndPrintException() {
try
{
throw new RuntimeException("BOOM!");
}
catch(RuntimeException exc)
{
StringWriter stringWrite = new StringWriter();
PrintWriter printWrite = new PrintWriter(stringWrite);
exc.printStackTrace(printWrite);
printWrite.flush();
printWrite.close();
System.out.println(stringWrite.toString());
}
}
This code prints out the same stacktrace for all locales in the list, no locale specific changes to the trace. If this is correct and expected then it seems I can assume that the java stacktraces received from around the world will always be formatted in english. Is this a correct assumption?