You may want to look into the work that NetBeans has done regarding automated use logging: http://wiki.netbeans.org/UsageLoggingSpecification.
As for dumping out local variables, I would imagine that you could simply use a debugger, such as the one that bajafresh4life mentioned.