1 16 package examples.lf5.InitUsingXMLPropertiesFile; 17 18 import org.apache.log4j.Logger; 19 import org.apache.log4j.xml.DOMConfigurator; 20 21 import java.io.IOException ; 22 import java.net.URL ; 23 24 34 35 37 public class InitUsingXMLPropertiesFile { 38 42 46 50 private static Logger logger = 51 Logger.getLogger(InitUsingXMLPropertiesFile.class); 52 53 57 61 public static void main(String argv[]) { 62 String resource = 64 "/examples/lf5/InitUsingXMLPropertiesFile/example.xml"; 65 URL configFileResource = 66 InitUsingXMLPropertiesFile.class.getResource(resource); 67 DOMConfigurator.configure(configFileResource.getFile()); 68 69 logger.debug("Hello, my name is Homer Simpson."); 71 logger.debug("Hello, my name is Lisa Simpson."); 72 logger.debug("Hello, my name is Marge Simpson."); 73 logger.debug("Hello, my name is Bart Simpson."); 74 logger.debug("Hello, my name is Maggie Simpson."); 75 76 logger.info("We are the Simpsons!"); 77 logger.info("Mmmmmm .... Chocolate."); 78 logger.info("Homer likes chocolate"); 79 logger.info("Doh!"); 80 logger.info("We are the Simpsons!"); 81 82 logger.warn("Bart: I am through with working! Working is for chumps!" + 83 "Homer: Son, I'm proud of you. I was twice your age before " + 84 "I figured that out."); 85 logger.warn("Mmm...forbidden donut."); 86 logger.warn("D'oh! A deer! A female deer!"); 87 logger.warn("Truly, yours is a butt that won't quit." + 88 "- Bart, writing as Woodrow to Ms. Krabappel."); 89 90 logger.error("Dear Baby, Welcome to Dumpsville. Population: you."); 91 logger.error("Dear Baby, Welcome to Dumpsville. Population: you.", 92 new IOException ("Dumpsville, USA")); 93 logger.error("Mr. Hutz, are you aware you're not wearing pants?"); 94 logger.error("Mr. Hutz, are you aware you're not wearing pants?", 95 new IllegalStateException ("Error !!")); 96 97 98 logger.fatal("Eep."); 99 logger.fatal("Mmm...forbidden donut.", 100 new SecurityException ("Fatal Exception")); 101 logger.fatal("D'oh! A deer! A female deer!"); 102 logger.fatal("Mmmmmm .... Chocolate.", 103 new SecurityException ("Fatal Exception")); 104 } 105 106 110 114 118 } 119 | Popular Tags |