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