1 16 17 package org.apache.log4j.helpers; 18 19 import org.apache.log4j.spi.ErrorHandler; 20 import org.apache.log4j.spi.LoggingEvent; 21 import org.apache.log4j.Logger; 22 import org.apache.log4j.Appender; 23 24 37 public class OnlyOnceErrorHandler implements ErrorHandler { 38 39 40 final String WARN_PREFIX = "log4j warning: "; 41 final String ERROR_PREFIX = "log4j error: "; 42 43 boolean firstTime = true; 44 45 46 49 public 50 void setLogger(Logger logger) { 51 } 52 53 54 57 public 58 void activateOptions() { 59 } 60 61 62 65 public 66 void error(String message, Exception e, int errorCode) { 67 error(message, e, errorCode, null); 68 } 69 70 74 public 75 void error(String message, Exception e, int errorCode, LoggingEvent event) { 76 if(firstTime) { 77 LogLog.error(message, e); 78 firstTime = false; 79 } 80 } 81 82 83 87 public 88 void error(String message) { 89 if(firstTime) { 90 LogLog.error(message); 91 firstTime = false; 92 } 93 } 94 95 98 public 99 void setAppender(Appender appender) { 100 } 101 102 105 public 106 void setBackupAppender(Appender appender) { 107 } 108 } 109 | Popular Tags |