是否有任何库可以通过添加注释来记录变量:
@Log String someValueToLog = someMethod(); @Log(level="debug",prefix="Here's the value=") String someValueToLogAgain = someMethod();
log.info(someValueToLog); log.debug("Here's the value="+someValueToLogAgain);
解决方法
您需要为此编写自定义注释.这是一个尝试使用aspectj AOP:
http://javakane.blogspot.ro/2012/07/automate-log4j-logging-with-aop-and.html
http://javakane.blogspot.ro/2012/07/automate-log4j-logging-with-aop-and.html