This question already has an answer here:
Is there a way to get the Names & Values of Java declared-variables in a java function() ?
I know how to get global class variables through Reflection using the following code.
Field[] fields = this.getClass().getDeclaredFields();
for(Field field: fields)
{
System.out.println("Name="+ field.getName()+"/Value="+ field.toString()+" / "+field.get(this));
}
But how do I get to the Locally declared variables in a function()?
My objective is to log all variables to logfile upon exception
try{}catch(Exception e){/*code goes here*/}
Aucun commentaire:
Enregistrer un commentaire