1 16 17 18 package org.apache.commons.logging.impl; 19 20 import org.apache.commons.logging.Log; 21 import org.apache.log4j.Category; 22 import org.apache.log4j.Priority; 23 24 37 public final class Log4JCategoryLog implements Log { 38 39 40 42 43 private static final String FQCN = Log4JCategoryLog.class.getName(); 44 45 46 private Category category = null; 47 48 49 51 public Log4JCategoryLog() { 52 } 53 54 55 58 public Log4JCategoryLog(String name) { 59 this.category=Category.getInstance(name); 60 } 61 62 64 public Log4JCategoryLog(Category category ) { 65 this.category=category; 66 } 67 68 69 71 72 76 public void trace(Object message) { 77 category.log(FQCN, Priority.DEBUG, message, null); 78 } 79 80 81 85 public void trace(Object message, Throwable t) { 86 category.log(FQCN, Priority.DEBUG, message, t ); 87 } 88 89 90 93 public void debug(Object message) { 94 category.log(FQCN, Priority.DEBUG, message, null); 95 } 96 97 100 public void debug(Object message, Throwable t) { 101 category.log(FQCN, Priority.DEBUG, message, t ); 102 } 103 104 105 108 public void info(Object message) { 109 category.log(FQCN, Priority.INFO, message, null ); 110 } 111 112 113 116 public void info(Object message, Throwable t) { 117 category.log(FQCN, Priority.INFO, message, t ); 118 } 119 120 121 124 public void warn(Object message) { 125 category.log(FQCN, Priority.WARN, message, null ); 126 } 127 128 129 132 public void warn(Object message, Throwable t) { 133 category.log(FQCN, Priority.WARN, message, t ); 134 } 135 136 137 140 public void error(Object message) { 141 category.log(FQCN, Priority.ERROR, message, null ); 142 } 143 144 145 148 public void error(Object message, Throwable t) { 149 category.log(FQCN, Priority.ERROR, message, t ); 150 } 151 152 153 156 public void fatal(Object message) { 157 category.log(FQCN, Priority.FATAL, message, null ); 158 } 159 160 161 164 public void fatal(Object message, Throwable t) { 165 category.log(FQCN, Priority.FATAL, message, t ); 166 } 167 168 169 172 public Category getCategory() { 173 return (this.category); 174 } 175 176 177 180 public boolean isDebugEnabled() { 181 return category.isDebugEnabled(); 182 } 183 184 185 188 public boolean isErrorEnabled() { 189 return category.isEnabledFor(Priority.ERROR); 190 } 191 192 193 196 public boolean isFatalEnabled() { 197 return category.isEnabledFor(Priority.FATAL); 198 } 199 200 201 204 public boolean isInfoEnabled() { 205 return category.isInfoEnabled(); 206 } 207 208 209 213 public boolean isTraceEnabled() { 214 return category.isDebugEnabled(); 215 } 216 217 220 public boolean isWarnEnabled() { 221 return category.isEnabledFor(Priority.WARN); 222 } 223 } 224 | Popular Tags |