1 16 package org.directwebremoting.util; 17 18 25 public final class Logger 26 { 27 31 public static Logger getLogger(Class base) 32 { 33 return new Logger(base); 34 } 35 36 40 private Logger(Class base) 41 { 42 if (!commonsLoggingTried) 43 { 44 try 45 { 46 LoggingOutput internal = new CommonsLoggingOutput(Logger.class); 47 internal.debug("Logging using commons-logging."); 48 commonsLoggingAvailable = true; 49 } 50 catch (NoClassDefFoundError ex) 51 { 52 LoggingOutput internal = new ServletLoggingOutput(); 53 internal.debug("Logging using servlet.log."); 54 commonsLoggingAvailable = false; 55 } 56 57 commonsLoggingTried = true; 58 } 59 60 if (commonsLoggingAvailable) 61 { 62 output = new CommonsLoggingOutput(base); 63 } 64 else 65 { 66 output = new ServletLoggingOutput(); 67 } 68 } 69 70 73 private LoggingOutput output; 74 75 private static boolean commonsLoggingTried = false; 76 77 private static boolean commonsLoggingAvailable = false; 78 79 83 public void debug(String message) 84 { 85 output.debug(message); 86 } 87 88 92 public void info(String message) 93 { 94 output.info(message); 95 } 96 97 101 public void warn(String message) 102 { 103 output.warn(message); 104 } 105 106 111 public void warn(String message, Throwable th) 112 { 113 output.warn(message, th); 114 } 115 116 120 public void error(String message) 121 { 122 output.error(message); 123 } 124 125 130 public void error(String message, Throwable th) 131 { 132 output.error(message, th); 133 } 134 135 139 public void fatal(String message) 140 { 141 output.fatal(message); 142 } 143 144 149 public void fatal(String message, Throwable th) 150 { 151 output.fatal(message, th); 152 } 153 154 158 public boolean isDebugEnabled() 159 { 160 return output.isDebugEnabled(); 161 } 162 } 163 | Popular Tags |