Lines 35-42
Link Here
|
35 |
import org.apache.log4j.spi.LoggingEvent; |
35 |
import org.apache.log4j.spi.LoggingEvent; |
36 |
import org.apache.log4j.spi.LoggerRepository; |
36 |
import org.apache.log4j.spi.LoggerRepository; |
37 |
import org.apache.log4j.spi.HierarchyEventListener; |
37 |
import org.apache.log4j.spi.HierarchyEventListener; |
|
|
38 |
import org.apache.log4j.spi.NOPLoggerRepository; |
38 |
import org.apache.log4j.helpers.NullEnumeration; |
39 |
import org.apache.log4j.helpers.NullEnumeration; |
39 |
import org.apache.log4j.helpers.AppenderAttachableImpl; |
40 |
import org.apache.log4j.helpers.AppenderAttachableImpl; |
|
|
41 |
import org.apache.log4j.helpers.LogLog; |
40 |
|
42 |
|
41 |
import java.util.Enumeration; |
43 |
import java.util.Enumeration; |
42 |
import java.util.MissingResourceException; |
44 |
import java.util.MissingResourceException; |
Lines 120-126
Link Here
|
120 |
protected ResourceBundle resourceBundle; |
122 |
protected ResourceBundle resourceBundle; |
121 |
|
123 |
|
122 |
// Categories need to know what Hierarchy they are in |
124 |
// Categories need to know what Hierarchy they are in |
123 |
protected LoggerRepository repository; |
125 |
private LoggerRepository repository; |
|
|
126 |
// Remember who set the repository to null |
127 |
private Exception nulledBy; |
124 |
|
128 |
|
125 |
|
129 |
|
126 |
AppenderAttachableImpl aai; |
130 |
AppenderAttachableImpl aai; |
Lines 162-168
Link Here
|
162 |
aai = new AppenderAttachableImpl(); |
166 |
aai = new AppenderAttachableImpl(); |
163 |
} |
167 |
} |
164 |
aai.addAppender(newAppender); |
168 |
aai.addAppender(newAppender); |
165 |
repository.fireAddAppenderEvent(this, newAppender); |
169 |
getLoggerRepository().fireAddAppenderEvent(this, newAppender); |
166 |
} |
170 |
} |
167 |
|
171 |
|
168 |
/** |
172 |
/** |
Lines 212-218
Link Here
|
212 |
} |
216 |
} |
213 |
|
217 |
|
214 |
if(writes == 0) { |
218 |
if(writes == 0) { |
215 |
repository.emitNoAppenderWarning(this); |
219 |
getLoggerRepository().emitNoAppenderWarning(this); |
216 |
} |
220 |
} |
217 |
} |
221 |
} |
218 |
|
222 |
|
Lines 254-260
Link Here
|
254 |
@param message the message object to log. */ |
258 |
@param message the message object to log. */ |
255 |
public |
259 |
public |
256 |
void debug(Object message) { |
260 |
void debug(Object message) { |
257 |
if(repository.isDisabled(Level.DEBUG_INT)) |
261 |
if(getLoggerRepository().isDisabled(Level.DEBUG_INT)) |
258 |
return; |
262 |
return; |
259 |
if(Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) { |
263 |
if(Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) { |
260 |
forcedLog(FQCN, Level.DEBUG, message, null); |
264 |
forcedLog(FQCN, Level.DEBUG, message, null); |
Lines 273-279
Link Here
|
273 |
@param t the exception to log, including its stack trace. */ |
277 |
@param t the exception to log, including its stack trace. */ |
274 |
public |
278 |
public |
275 |
void debug(Object message, Throwable t) { |
279 |
void debug(Object message, Throwable t) { |
276 |
if(repository.isDisabled(Level.DEBUG_INT)) |
280 |
if(getLoggerRepository().isDisabled(Level.DEBUG_INT)) |
277 |
return; |
281 |
return; |
278 |
if(Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) |
282 |
if(Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) |
279 |
forcedLog(FQCN, Level.DEBUG, message, t); |
283 |
forcedLog(FQCN, Level.DEBUG, message, t); |
Lines 299-305
Link Here
|
299 |
@param message the message object to log */ |
303 |
@param message the message object to log */ |
300 |
public |
304 |
public |
301 |
void error(Object message) { |
305 |
void error(Object message) { |
302 |
if(repository.isDisabled(Level.ERROR_INT)) |
306 |
if(getLoggerRepository().isDisabled(Level.ERROR_INT)) |
303 |
return; |
307 |
return; |
304 |
if(Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel())) |
308 |
if(Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel())) |
305 |
forcedLog(FQCN, Level.ERROR, message, null); |
309 |
forcedLog(FQCN, Level.ERROR, message, null); |
Lines 316-322
Link Here
|
316 |
@param t the exception to log, including its stack trace. */ |
320 |
@param t the exception to log, including its stack trace. */ |
317 |
public |
321 |
public |
318 |
void error(Object message, Throwable t) { |
322 |
void error(Object message, Throwable t) { |
319 |
if(repository.isDisabled(Level.ERROR_INT)) |
323 |
if(getLoggerRepository().isDisabled(Level.ERROR_INT)) |
320 |
return; |
324 |
return; |
321 |
if(Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel())) |
325 |
if(Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel())) |
322 |
forcedLog(FQCN, Level.ERROR, message, t); |
326 |
forcedLog(FQCN, Level.ERROR, message, t); |
Lines 359-365
Link Here
|
359 |
@param message the message object to log */ |
363 |
@param message the message object to log */ |
360 |
public |
364 |
public |
361 |
void fatal(Object message) { |
365 |
void fatal(Object message) { |
362 |
if(repository.isDisabled(Level.FATAL_INT)) |
366 |
if(getLoggerRepository().isDisabled(Level.FATAL_INT)) |
363 |
return; |
367 |
return; |
364 |
if(Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel())) |
368 |
if(Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel())) |
365 |
forcedLog(FQCN, Level.FATAL, message, null); |
369 |
forcedLog(FQCN, Level.FATAL, message, null); |
Lines 376-382
Link Here
|
376 |
@param t the exception to log, including its stack trace. */ |
380 |
@param t the exception to log, including its stack trace. */ |
377 |
public |
381 |
public |
378 |
void fatal(Object message, Throwable t) { |
382 |
void fatal(Object message, Throwable t) { |
379 |
if(repository.isDisabled(Level.FATAL_INT)) |
383 |
if(getLoggerRepository().isDisabled(Level.FATAL_INT)) |
380 |
return; |
384 |
return; |
381 |
if(Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel())) |
385 |
if(Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel())) |
382 |
forcedLog(FQCN, Level.FATAL, message, t); |
386 |
forcedLog(FQCN, Level.FATAL, message, t); |
Lines 499-505
Link Here
|
499 |
@since 1.1 */ |
503 |
@since 1.1 */ |
500 |
public |
504 |
public |
501 |
LoggerRepository getHierarchy() { |
505 |
LoggerRepository getHierarchy() { |
502 |
return repository; |
506 |
return getLoggerRepository(); |
503 |
} |
507 |
} |
504 |
|
508 |
|
505 |
/** |
509 |
/** |
Lines 509-514
Link Here
|
509 |
@since 1.2 */ |
513 |
@since 1.2 */ |
510 |
public |
514 |
public |
511 |
LoggerRepository getLoggerRepository() { |
515 |
LoggerRepository getLoggerRepository() { |
|
|
516 |
if (repository == null) { |
517 |
LogLog.error("Category.repository was null likely due to error in class reloading or someone setting it to null. Using NOPLoggerRepository.", nulledBy); |
518 |
repository = new NOPLoggerRepository(); |
519 |
} |
512 |
return repository; |
520 |
return repository; |
513 |
} |
521 |
} |
514 |
|
522 |
|
Lines 660-666
Link Here
|
660 |
@param message the message object to log */ |
668 |
@param message the message object to log */ |
661 |
public |
669 |
public |
662 |
void info(Object message) { |
670 |
void info(Object message) { |
663 |
if(repository.isDisabled(Level.INFO_INT)) |
671 |
if(getLoggerRepository().isDisabled(Level.INFO_INT)) |
664 |
return; |
672 |
return; |
665 |
if(Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) |
673 |
if(Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) |
666 |
forcedLog(FQCN, Level.INFO, message, null); |
674 |
forcedLog(FQCN, Level.INFO, message, null); |
Lines 677-683
Link Here
|
677 |
@param t the exception to log, including its stack trace. */ |
685 |
@param t the exception to log, including its stack trace. */ |
678 |
public |
686 |
public |
679 |
void info(Object message, Throwable t) { |
687 |
void info(Object message, Throwable t) { |
680 |
if(repository.isDisabled(Level.INFO_INT)) |
688 |
if(getLoggerRepository().isDisabled(Level.INFO_INT)) |
681 |
return; |
689 |
return; |
682 |
if(Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) |
690 |
if(Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) |
683 |
forcedLog(FQCN, Level.INFO, message, t); |
691 |
forcedLog(FQCN, Level.INFO, message, t); |
Lines 731-737
Link Here
|
731 |
* */ |
739 |
* */ |
732 |
public |
740 |
public |
733 |
boolean isDebugEnabled() { |
741 |
boolean isDebugEnabled() { |
734 |
if(repository.isDisabled( Level.DEBUG_INT)) |
742 |
if(getLoggerRepository().isDisabled( Level.DEBUG_INT)) |
735 |
return false; |
743 |
return false; |
736 |
return Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel()); |
744 |
return Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel()); |
737 |
} |
745 |
} |
Lines 746-752
Link Here
|
746 |
*/ |
754 |
*/ |
747 |
public |
755 |
public |
748 |
boolean isEnabledFor(Priority level) { |
756 |
boolean isEnabledFor(Priority level) { |
749 |
if(repository.isDisabled(level.level)) |
757 |
if(getLoggerRepository().isDisabled(level.level)) |
750 |
return false; |
758 |
return false; |
751 |
return level.isGreaterOrEqual(this.getEffectiveLevel()); |
759 |
return level.isGreaterOrEqual(this.getEffectiveLevel()); |
752 |
} |
760 |
} |
Lines 760-766
Link Here
|
760 |
*/ |
768 |
*/ |
761 |
public |
769 |
public |
762 |
boolean isInfoEnabled() { |
770 |
boolean isInfoEnabled() { |
763 |
if(repository.isDisabled(Level.INFO_INT)) |
771 |
if(getLoggerRepository().isDisabled(Level.INFO_INT)) |
764 |
return false; |
772 |
return false; |
765 |
return Level.INFO.isGreaterOrEqual(this.getEffectiveLevel()); |
773 |
return Level.INFO.isGreaterOrEqual(this.getEffectiveLevel()); |
766 |
} |
774 |
} |
Lines 776-782
Link Here
|
776 |
@since 0.8.4 */ |
784 |
@since 0.8.4 */ |
777 |
public |
785 |
public |
778 |
void l7dlog(Priority priority, String key, Throwable t) { |
786 |
void l7dlog(Priority priority, String key, Throwable t) { |
779 |
if(repository.isDisabled(priority.level)) { |
787 |
if(getLoggerRepository().isDisabled(priority.level)) { |
780 |
return; |
788 |
return; |
781 |
} |
789 |
} |
782 |
if(priority.isGreaterOrEqual(this.getEffectiveLevel())) { |
790 |
if(priority.isGreaterOrEqual(this.getEffectiveLevel())) { |
Lines 800-806
Link Here
|
800 |
*/ |
808 |
*/ |
801 |
public |
809 |
public |
802 |
void l7dlog(Priority priority, String key, Object[] params, Throwable t) { |
810 |
void l7dlog(Priority priority, String key, Object[] params, Throwable t) { |
803 |
if(repository.isDisabled(priority.level)) { |
811 |
if(getLoggerRepository().isDisabled(priority.level)) { |
804 |
return; |
812 |
return; |
805 |
} |
813 |
} |
806 |
if(priority.isGreaterOrEqual(this.getEffectiveLevel())) { |
814 |
if(priority.isGreaterOrEqual(this.getEffectiveLevel())) { |
Lines 819-825
Link Here
|
819 |
*/ |
827 |
*/ |
820 |
public |
828 |
public |
821 |
void log(Priority priority, Object message, Throwable t) { |
829 |
void log(Priority priority, Object message, Throwable t) { |
822 |
if(repository.isDisabled(priority.level)) { |
830 |
if(getLoggerRepository().isDisabled(priority.level)) { |
823 |
return; |
831 |
return; |
824 |
} |
832 |
} |
825 |
if(priority.isGreaterOrEqual(this.getEffectiveLevel())) |
833 |
if(priority.isGreaterOrEqual(this.getEffectiveLevel())) |
Lines 831-837
Link Here
|
831 |
*/ |
839 |
*/ |
832 |
public |
840 |
public |
833 |
void log(Priority priority, Object message) { |
841 |
void log(Priority priority, Object message) { |
834 |
if(repository.isDisabled(priority.level)) { |
842 |
if(getLoggerRepository().isDisabled(priority.level)) { |
835 |
return; |
843 |
return; |
836 |
} |
844 |
} |
837 |
if(priority.isGreaterOrEqual(this.getEffectiveLevel())) |
845 |
if(priority.isGreaterOrEqual(this.getEffectiveLevel())) |
Lines 849-855
Link Here
|
849 |
@param t The throwable of the logging request, may be null. */ |
857 |
@param t The throwable of the logging request, may be null. */ |
850 |
public |
858 |
public |
851 |
void log(String callerFQCN, Priority level, Object message, Throwable t) { |
859 |
void log(String callerFQCN, Priority level, Object message, Throwable t) { |
852 |
if(repository.isDisabled(level.level)) { |
860 |
if(getLoggerRepository().isDisabled(level.level)) { |
853 |
return; |
861 |
return; |
854 |
} |
862 |
} |
855 |
if(level.isGreaterOrEqual(this.getEffectiveLevel())) { |
863 |
if(level.isGreaterOrEqual(this.getEffectiveLevel())) { |
Lines 942-949
Link Here
|
942 |
/** |
950 |
/** |
943 |
Only the Hiearchy class can set the hiearchy of a |
951 |
Only the Hiearchy class can set the hiearchy of a |
944 |
category. Default package access is MANDATORY here. */ |
952 |
category. Default package access is MANDATORY here. */ |
|
|
953 |
protected // TODO Must be protected for NOPLogger and CategoryTest. |
945 |
final |
954 |
final |
946 |
void setHierarchy(LoggerRepository repository) { |
955 |
void setHierarchy(LoggerRepository repository) { |
|
|
956 |
nulledBy = null; |
957 |
if (repository == null) { |
958 |
nulledBy = new Exception("Repository was nulled here."); |
959 |
} |
947 |
this.repository = repository; |
960 |
this.repository = repository; |
948 |
} |
961 |
} |
949 |
|
962 |
|
Lines 1036-1042
Link Here
|
1036 |
@param message the message object to log. */ |
1049 |
@param message the message object to log. */ |
1037 |
public |
1050 |
public |
1038 |
void warn(Object message) { |
1051 |
void warn(Object message) { |
1039 |
if(repository.isDisabled( Level.WARN_INT)) |
1052 |
if(getLoggerRepository().isDisabled( Level.WARN_INT)) |
1040 |
return; |
1053 |
return; |
1041 |
|
1054 |
|
1042 |
if(Level.WARN.isGreaterOrEqual(this.getEffectiveLevel())) |
1055 |
if(Level.WARN.isGreaterOrEqual(this.getEffectiveLevel())) |
Lines 1054-1060
Link Here
|
1054 |
@param t the exception to log, including its stack trace. */ |
1067 |
@param t the exception to log, including its stack trace. */ |
1055 |
public |
1068 |
public |
1056 |
void warn(Object message, Throwable t) { |
1069 |
void warn(Object message, Throwable t) { |
1057 |
if(repository.isDisabled(Level.WARN_INT)) |
1070 |
if(getLoggerRepository().isDisabled(Level.WARN_INT)) |
1058 |
return; |
1071 |
return; |
1059 |
if(Level.WARN.isGreaterOrEqual(this.getEffectiveLevel())) |
1072 |
if(Level.WARN.isGreaterOrEqual(this.getEffectiveLevel())) |
1060 |
forcedLog(FQCN, Level.WARN, message, t); |
1073 |
forcedLog(FQCN, Level.WARN, message, t); |