1 16 package examples.lf5.InitUsingMultipleAppenders; 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 60 61 63 public class InitUsingMultipleAppenders { 64 65 69 73 77 private static Logger logger = 78 Logger.getLogger(InitUsingMultipleAppenders.class); 79 80 84 88 public static void main(String argv[]) { 89 String resource = 91 "/examples/lf5/InitUsingMultipleAppenders/example.properties"; 92 URL configFileResource = 93 InitUsingMultipleAppenders.class.getResource(resource); 94 PropertyConfigurator.configure(configFileResource); 95 96 logger.debug("Hello, my name is Homer Simpson."); 98 logger.debug("Hello, my name is Lisa Simpson."); 99 logger.debug("Hello, my name is Marge Simpson."); 100 logger.debug("Hello, my name is Bart Simpson."); 101 logger.debug("Hello, my name is Maggie Simpson."); 102 103 logger.info("We are the Simpsons!"); 104 logger.info("Mmmmmm .... Chocolate."); 105 logger.info("Homer likes chocolate"); 106 logger.info("Doh!"); 107 logger.info("We are the Simpsons!"); 108 109 logger.warn("Bart: I am through with working! Working is for chumps!" + 110 "Homer: Son, I'm proud of you. I was twice your age before " + 111 "I figured that out."); 112 logger.warn("Mmm...forbidden donut."); 113 logger.warn("D'oh! A deer! A female deer!"); 114 logger.warn("Truly, yours is a butt that won't quit." + 115 "- Bart, writing as Woodrow to Ms. Krabappel."); 116 117 logger.error("Dear Baby, Welcome to Dumpsville. Population: you."); 118 logger.error("Dear Baby, Welcome to Dumpsville. Population: you.", 119 new IOException ("Dumpsville, USA")); 120 logger.error("Mr. Hutz, are you aware you're not wearing pants?"); 121 logger.error("Mr. Hutz, are you aware you're not wearing pants?", 122 new IllegalStateException ("Error !!")); 123 124 125 logger.fatal("Eep."); 126 logger.fatal("Mmm...forbidden donut.", 127 new SecurityException ("Fatal Exception")); 128 logger.fatal("D'oh! A deer! A female deer!"); 129 logger.fatal("Mmmmmm .... Chocolate.", 130 new SecurityException ("Fatal Exception")); 131 } 132 133 137 141 145 } 146 | Popular Tags |