import org.apache.log4j.Logger; public class InnerClassLogger { static Logger loggerA = Logger.getLogger(InnerClassLogger.class); public static void main(String[] args) { loggerA.info(new Object(){ @Override public String toString(){ loggerA.info("loggerB"); return ""; } }); } }
输出:
0 [main] INFO InnerClassLogger - loggerB
0 [main] INFO InnerClassLogger - loggerB