How do you programatically get access to the names and contents of all variables
in the current variable scope ?
(attributes and local variables in the current method)

I am usually mostly interested in Strings and the primitive datatype
int , but any objects toString() representation might also be of interest.

What I would like to do, is to *avoid* manually concatenating here and there
in
the code like the ugly code example below, and being able to let
java itself figure out what attributes and local variables that currently
exist in the
method with the code.

As an example, I would like to be able to replace hardcoded code like this:
<pre>
try {
// ... some code...
}
catch(myException e) {
String s = "An exception occurred in myClass.myMethod, when the
attributes and local variables had the following values: ";
s += " myStringAttribute = " + myStringAttribute ;
s += ", myIntAttribute = " + myIntAttribute;
s += ", myLocalString = " + myLocalString;
s += ", myLocalInt = " + myLocalInt;
writeToLogfile(s);
}
</pre>

with call to some general method which automatically retrieves a string with
the names
and the contents of all attributes and local variables, kind of like this:
<pre>
try {
// ... some code...
}
catch(myException e) {
String s = "An exception occurred in myClass.myMethod, when the attributes
and local variables had the following values: ";
s += SomeClass.getStringWithAllVariableNamesAndValues(); // Here the requested
method is called
writeToLogfile(s);
}
</pre>

Does it exist such a class and method in the standard java distribution,
or as a third party class ?