1 17 18 19 20 package org.apache.lenya.util; 21 22 import org.apache.log4j.Category; 23 24 25 28 public class Log4Echo { 29 private static Category log = Category.getInstance(Log4Echo.class); 30 31 36 public static void main(String [] args) { 37 if (args.length != 2) { 38 System.err.println("Usage: java " + new Log4Echo().getClass().getName() + "log-level log-message"); 39 return; 40 } 41 42 String level = args[0].toLowerCase(); 43 String message = args[1]; 44 if (level.equals("debug")) { 45 log.debug(message); 46 } else if (level.equals("info")) { 47 log.info(message); 48 } else if (level.equals("warn")) { 49 log.warn(message); 50 } else if (level.equals("error")) { 51 log.error(message); 52 } else if (level.equals("fatal")) { 53 log.fatal(message); 54 } else { 55 log.error("No such log level: " + level + " " + message); 56 } 57 } 58 } 59 | Popular Tags |