1 18 19 package cowsultants.itracker.ejb.client.util; 20 21 import java.rmi.*; 22 import java.util.*; 23 import javax.rmi.*; 24 import javax.naming.*; 25 26 import org.apache.log4j.*; 27 28 import cowsultants.itracker.ejb.client.interfaces.*; 29 30 public class Logger { 31 private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("cowsultants.ITracker"); 32 private static String logLevel = "DEBUG"; 33 34 static { 35 Enumeration appenders = logger.getAllAppenders(); 36 if(! appenders.hasMoreElements() && ! logger.getRootLogger().getAllAppenders().hasMoreElements()) { 37 logger.setLevel((Level) Level.toLevel(logLevel)); 39 logger.addAppender(new ConsoleAppender(new PatternLayout("%d{ABSOLUTE} %-5p [%c{1}] %m%n"))); 40 logger.info("Could not determine current configuration, adding new ConsoleAppender, setting logLevel to " + logLevel); 41 } 42 } 43 44 public static boolean isLoggingDebug() { 45 return logger.isDebugEnabled(); 46 } 47 48 public static boolean isLoggingInfo() { 49 return logger.isInfoEnabled(); 50 } 51 52 public static void logDebug(String message) { 53 logger.debug(message); 54 } 55 56 public static void logDebug(String location, String message) { 57 logger.debug(location + ": " + message); 58 } 59 60 public static void logDebug(String message, Throwable t) { 61 logger.debug(message, t); 62 } 63 64 public static void logInfo(String message) { 65 logger.info(message); 66 } 67 68 public static void logInfo(String location, String message) { 69 logger.info(location + ": " + message); 70 } 71 72 public static void logInfo(String message, Throwable t) { 73 logger.info(message, t); 74 } 75 76 public static void logWarn(String message) { 77 logger.warn(message); 78 } 79 80 public static void logWarn(String location, String message) { 81 logger.warn(location + ": " + message); 82 } 83 84 public static void logWarn(String message, Throwable t) { 85 logger.warn(message, t); 86 } 87 88 public static void logError(String message) { 89 logger.error(message); 90 } 91 92 public static void logError(String location, String message) { 93 logger.error(location + ": " + message); 94 } 95 96 public static void logError(String message, Throwable t) { 97 logger.error(message, t); 98 } 99 100 } | Popular Tags |