1 16 17 package examples; 18 19 20 import org.apache.log4j.Logger; 21 import org.apache.log4j.BasicConfigurator; 22 import org.apache.log4j.NDC; 23 24 49 public class Trivial { 50 51 static Logger logger = Logger.getLogger(Trivial.class); 52 53 public static void main(String [] args) { 54 BasicConfigurator.configure(); 55 NDC.push("Client #45890"); 56 57 logger.info("Awake awake. Put on thy strength."); 58 Trivial.foo(); 59 InnerTrivial.foo(); 60 logger.info("Exiting Trivial."); 61 } 62 63 static 64 void foo() { 65 NDC.push("DB"); 66 logger.debug("Now king David was old."); 67 NDC.pop(); 68 } 69 70 static class InnerTrivial { 71 static Logger logger = Logger.getLogger(InnerTrivial.class); 72 73 static 74 void foo() { 75 logger.info("Entered foo."); 76 } 77 } 78 } 79 | Popular Tags |