Java 类org.apache.log4j.spi.ErrorHandler 实例源码

项目:daq-eclipse    文件:PropertyConfigurator.java   
private void parseErrorHandler(
  final ErrorHandler eh,
  final String errorHandlerPrefix,
  final Properties props, 
  final LoggerRepository hierarchy) {
boolean rootRef = OptionConverter.toBoolean(
              OptionConverter.findAndSubst(errorHandlerPrefix + ROOT_REF, props), false);
if (rootRef) {
          eh.setLogger(hierarchy.getRootLogger());
   }
String loggerName = OptionConverter.findAndSubst(errorHandlerPrefix + LOGGER_REF , props);
if (loggerName != null) {
    Logger logger = (loggerFactory == null) ? hierarchy.getLogger(loggerName)
                    : hierarchy.getLogger(loggerName, loggerFactory);
    eh.setLogger(logger);
}
String appenderName = OptionConverter.findAndSubst(errorHandlerPrefix + APPENDER_REF_TAG, props);
if (appenderName != null) {
    Appender backup = parseAppender(props, appenderName);
    if (backup != null) {
        eh.setBackupAppender(backup);
    }
}
}
项目:cacheonix-core    文件:QuietWriter.java   
public
void setErrorHandler(ErrorHandler eh) {
  if(eh == null) {
    // This is a programming error on the part of the enclosing appender.
    throw new IllegalArgumentException("Attempted to set null ErrorHandler.");
  } else { 
    this.errorHandler = eh;
  }
}
项目:cacheonix-core    文件:AppenderSkeleton.java   
/** 
    Set the {@link ErrorHandler} for this Appender.
    @since 0.9.0
*/
public
synchronized
void setErrorHandler(ErrorHandler eh) {
  if(eh == null) {
    // We do not throw exception here since the cause is probably a
    // bad config file.
    LogLog.warn("You have tried to set a null error-handler.");
  } else {
    this.errorHandler = eh;
  }
}
项目:cacheonix-core    文件:WriterAppender.java   
/**
    Set the {@link ErrorHandler} for this WriterAppender and also the
    underlying {@link QuietWriter} if any. */
 public synchronized void setErrorHandler(ErrorHandler eh) {
   if(eh == null) {
     LogLog.warn("You have tried to set a null error-handler.");
   } else {
     this.errorHandler = eh;
     if(this.qw != null) {
this.qw.setErrorHandler(eh);
     }
   }
 }
项目:daq-eclipse    文件:QuietWriter.java   
public
void setErrorHandler(ErrorHandler eh) {
  if(eh == null) {
    // This is a programming error on the part of the enclosing appender.
    throw new IllegalArgumentException("Attempted to set null ErrorHandler.");
  } else { 
    this.errorHandler = eh;
  }
}
项目:daq-eclipse    文件:AppenderSkeleton.java   
/** 
    Set the {@link ErrorHandler} for this Appender.
    @since 0.9.0
*/
public
synchronized
void setErrorHandler(ErrorHandler eh) {
  if(eh == null) {
    // We do not throw exception here since the cause is probably a
    // bad config file.
    LogLog.warn("You have tried to set a null error-handler.");
  } else {
    this.errorHandler = eh;
  }
}
项目:daq-eclipse    文件:WriterAppender.java   
/**
    Set the {@link ErrorHandler} for this WriterAppender and also the
    underlying {@link QuietWriter} if any. */
 public synchronized void setErrorHandler(ErrorHandler eh) {
   if(eh == null) {
     LogLog.warn("You have tried to set a null error-handler.");
   } else {
     this.errorHandler = eh;
     if(this.qw != null) {
this.qw.setErrorHandler(eh);
     }
   }
 }
项目:daq-eclipse    文件:PropertySetter.java   
/**
   Convert <code>val</code> a String parameter to an object of a
   given type.
*/
protected
Object convertArg(String val, Class type) {
  if(val == null)
    return null;

  String v = val.trim();
  if (String.class.isAssignableFrom(type)) {
    return val;
  } else if (Integer.TYPE.isAssignableFrom(type)) {
    return new Integer(v);
  } else if (Long.TYPE.isAssignableFrom(type)) {
    return new Long(v);
  } else if (Boolean.TYPE.isAssignableFrom(type)) {
    if ("true".equalsIgnoreCase(v)) {
      return Boolean.TRUE;
    } else if ("false".equalsIgnoreCase(v)) {
      return Boolean.FALSE;
    }
  } else if (Priority.class.isAssignableFrom(type)) {
    return OptionConverter.toLevel(v, (Level) Level.DEBUG);
  } else if (ErrorHandler.class.isAssignableFrom(type)) {
    return OptionConverter.instantiateByClassName(v, 
 ErrorHandler.class, null);
  }
  return null;
}
项目:nabs    文件:QuietWriter.java   
public
void setErrorHandler(ErrorHandler eh) {
  if(eh == null) {
    // This is a programming error on the part of the enclosing appender.
    throw new IllegalArgumentException("Attempted to set null ErrorHandler.");
  } else { 
    this.errorHandler = eh;
  }
}
项目:nabs    文件:AppenderSkeleton.java   
/** 
    Set the {@link ErrorHandler} for this Appender.
    @since 0.9.0
*/
public
synchronized
void setErrorHandler(ErrorHandler eh) {
  if(eh == null) {
    // We do not throw exception here since the cause is probably a
    // bad config file.
    LogLog.warn("You have tried to set a null error-handler.");
  } else {
    this.errorHandler = eh;
  }
}
项目:nabs    文件:WriterAppender.java   
/**
    Set the {@link ErrorHandler} for this WriterAppender and also the
    underlying {@link QuietWriter} if any. */
 public synchronized void setErrorHandler(ErrorHandler eh) {
   if(eh == null) {
     LogLog.warn("You have tried to set a null error-handler.");
   } else {
     this.errorHandler = eh;
     if(this.qw != null) {
this.qw.setErrorHandler(eh);
     }
   }
 }
项目:spacewalk    文件:FallbackAppender.java   
/**
 * Constructor
 */
public FallbackAppender() {
    ErrorHandler fb = new FallbackErrorHandler();
    this.setErrorHandler(fb);
    fb.setAppender(this);
    Appender rootAppen = Logger.getRootLogger().getAppender("RootAppender");

    if (rootAppen != null) {
        fb.setBackupAppender(rootAppen);
    }

    Logger logger = Logger.getLogger(LoggingInvocationProcessor.class);
    fb.setLogger(logger);
}
项目:spacewalk    文件:FailbackAppender.java   
/**
 * Constructor
 */
public FailbackAppender() {
    ErrorHandler fb = new FallbackErrorHandler();
    this.setErrorHandler(fb);
    fb.setAppender(this);
    Appender rootAppen = Logger.getRootLogger().getAppender("RootAppender");

    if (rootAppen != null) {
        fb.setBackupAppender(rootAppen);
    }

    Logger logger = Logger.getLogger(LoggingInvocationProcessor.class);
    fb.setLogger(logger);
}
项目:logging-log4j2    文件:AppenderSkeleton.java   
/**
 * Set the {@link ErrorHandler} for this Appender.
 *
 * @since 0.9.0
 */
@Override
public synchronized void setErrorHandler(ErrorHandler eh) {
    if (eh != null) {
        this.errorHandler = eh;
    }
}
项目:sstore-soft    文件:StringAppender.java   
@Override
public ErrorHandler getErrorHandler() {
    // TODO Auto-generated method stub
    return null;
}
项目:sstore-soft    文件:StringAppender.java   
@Override
public void setErrorHandler(ErrorHandler arg0) {
    // TODO Auto-generated method stub
}
项目:s-store    文件:StringAppender.java   
@Override
public ErrorHandler getErrorHandler() {
    // TODO Auto-generated method stub
    return null;
}
项目:s-store    文件:StringAppender.java   
@Override
public void setErrorHandler(ErrorHandler arg0) {
    // TODO Auto-generated method stub
}
项目:FSTestTools    文件:SingleMessageAppender.java   
@Override
public void setErrorHandler(ErrorHandler errorHandler) {
    this.errorHandler = errorHandler;
}
项目:FSTestTools    文件:SingleMessageAppender.java   
@Override
public ErrorHandler getErrorHandler() {
    return errorHandler;
}
项目:FSTestTools    文件:AppenderForAsserts.java   
@Override
public ErrorHandler getErrorHandler() {
    return null;
}
项目:Log4jALA    文件:Log4jALAAppender.java   
@Override
public void setErrorHandler(ErrorHandler errorHandler) {
    super.setErrorHandler(errorHandler);
}
项目:Log4jALA    文件:Log4jALAAppender.java   
@Override
public ErrorHandler getErrorHandler() {
    return super.getErrorHandler();
}
项目:reladomo    文件:Log4JRecordingAppender.java   
public ErrorHandler getErrorHandler()
{
    return null;
}
项目:reladomo    文件:Log4JRecordingAppender.java   
public void setErrorHandler(ErrorHandler errorHandler)
{
}
项目:FSDevTools    文件:CliContextImplTest.java   
@Override
public ErrorHandler getErrorHandler() {
    return fallbackErrorHandler;
}
项目:jcode    文件:CountingQuietWriterEx.java   
public CountingQuietWriterEx(String key, String fileName, Writer writer, ErrorHandler eh) {
    super(writer, eh);
    this.key = key;
    this.fileName = fileName;
}
项目:cacheonix-core    文件:QuietWriter.java   
public
QuietWriter(Writer writer, ErrorHandler errorHandler) {
  super(writer);
  setErrorHandler(errorHandler);
}
项目:cacheonix-core    文件:SyslogQuietWriter.java   
public
SyslogQuietWriter(Writer writer, int syslogFacility, ErrorHandler eh) {
  super(writer, eh);
  this.syslogFacility = syslogFacility;
}
项目:cacheonix-core    文件:CountingQuietWriter.java   
public
CountingQuietWriter(Writer writer, ErrorHandler eh) {
  super(writer, eh);
}
项目:cacheonix-core    文件:DOMConfigurator.java   
/**
    Used internally to parse an {@link ErrorHandler} element.
  */
 protected
 void parseErrorHandler(Element element, Appender appender) {
   ErrorHandler eh = (ErrorHandler) OptionConverter.instantiateByClassName(
                                      subst(element.getAttribute(CLASS_ATTR)),
                                      org.apache.log4j.spi.ErrorHandler.class, 
                       null);

   if(eh != null) {
     eh.setAppender(appender);

     PropertySetter propSetter = new PropertySetter(eh);
     NodeList children = element.getChildNodes();
     final int length   = children.getLength();

     for (int loop = 0; loop < length; loop++) {
Node currentNode = children.item(loop);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
  Element currentElement = (Element) currentNode;
  String tagName = currentElement.getTagName();
  if(tagName.equals(PARAM_TAG)) {
           setParameter(currentElement, propSetter);
  } else if(tagName.equals(APPENDER_REF_TAG)) {
    eh.setBackupAppender(findAppenderByReference(currentElement));
  } else if(tagName.equals(LOGGER_REF)) {
    String loggerName = currentElement.getAttribute(REF_ATTR);      
    Logger logger = (catFactory == null) ? repository.getLogger(loggerName)
               : repository.getLogger(loggerName, catFactory);
    eh.setLogger(logger);
  } else if(tagName.equals(ROOT_REF)) {
    Logger root = repository.getRootLogger();
    eh.setLogger(root);
  } else {
         quietParseUnrecognizedElement(eh, currentElement, props);
     }
}
     }
     propSetter.activate();
     appender.setErrorHandler(eh);
   }
 }
项目:vso-intellij    文件:TestAppender.java   
@Override
public ErrorHandler getErrorHandler() {
    return null;
}
项目:log4j-http-appender    文件:HttpThread.java   
public HttpThread(HttpClient httpClient, ErrorHandler errorHandler) {
    this.httpClient = httpClient;
    this.errorHandler = errorHandler;
}
项目:fauxjsp    文件:TestLog4jLogging.java   
@Test
public void testLogging() {
    Log4jFactory factory = new Log4jFactory();
    org.apache.log4j.Logger loggerImpl= org.apache.log4j.Logger.getLogger("testlogger");

    final StringBuffer sb = new StringBuffer();
    loggerImpl.addAppender(new Appender() {

        @Override
        public void setName(String name) {
        }

        @Override
        public void setLayout(Layout layout) {
        }

        @Override
        public void setErrorHandler(ErrorHandler errorHandler) {
        }

        @Override
        public boolean requiresLayout() {
            return false;
        }

        @Override
        public String getName() {
            return null;
        }

        @Override
        public Layout getLayout() {
            return null;
        }

        @Override
        public Filter getFilter() {
            return null;
        }

        @Override
        public ErrorHandler getErrorHandler() {
            return null;
        }

        @Override
        public void doAppend(LoggingEvent event) {
            sb.append(event.getLevel()+" "+event.getMessage()+"\n");
        }

        @Override
        public void close() {
        }

        @Override
        public void clearFilters() {
        }

        @Override
        public void addFilter(Filter newFilter) {
        }
    });
    Logger logger = factory.getLogger("testlogger");
    logger.trace("trace message");
    logger.debug("debug message");
    logger.info("info message");
    logger.warn("warn message");
    logger.error("error message");
    logger.error("error exception", new RuntimeException("Testing error logger, please ignore this exception"));

    String expected = "INFO info message\n" + "WARN warn message\n" + "ERROR error message\n"
            + "ERROR error exception\n";
    Assert.assertEquals(expected, sb.toString());
}
项目:daq-eclipse    文件:QuietWriter.java   
public
QuietWriter(Writer writer, ErrorHandler errorHandler) {
  super(writer);
  setErrorHandler(errorHandler);
}
项目:daq-eclipse    文件:SyslogQuietWriter.java   
public
SyslogQuietWriter(Writer writer, int syslogFacility, ErrorHandler eh) {
  super(writer, eh);
  this.syslogFacility = syslogFacility;
}
项目:daq-eclipse    文件:CountingQuietWriter.java   
public
CountingQuietWriter(Writer writer, ErrorHandler eh) {
  super(writer, eh);
}
项目:daq-eclipse    文件:PropertyConfigurator.java   
Appender parseAppender(Properties props, String appenderName) {
   Appender appender = registryGet(appenderName);
   if((appender != null)) {
     LogLog.debug("Appender \"" + appenderName + "\" was already parsed.");
     return appender;
   }
   // Appender was not previously initialized.
   String prefix = APPENDER_PREFIX + appenderName;
   String layoutPrefix = prefix + ".layout";

   appender = (Appender) OptionConverter.instantiateByKey(props, prefix,
                      org.apache.log4j.Appender.class,
                      null);
   if(appender == null) {
     LogLog.error(
             "Could not instantiate appender named \"" + appenderName+"\".");
     return null;
   }
   appender.setName(appenderName);

   if(appender instanceof OptionHandler) {
     if(appender.requiresLayout()) {
Layout layout = (Layout) OptionConverter.instantiateByKey(props,
                              layoutPrefix,
                              Layout.class,
                              null);
if(layout != null) {
  appender.setLayout(layout);
  LogLog.debug("Parsing layout options for \"" + appenderName +"\".");
  //configureOptionHandler(layout, layoutPrefix + ".", props);
         PropertySetter.setProperties(layout, props, layoutPrefix + ".");
  LogLog.debug("End of parsing for \"" + appenderName +"\".");
}
     }
     final String errorHandlerPrefix = prefix + ".errorhandler";
     String errorHandlerClass = OptionConverter.findAndSubst(errorHandlerPrefix, props);
     if (errorHandlerClass != null) {
        ErrorHandler eh = (ErrorHandler) OptionConverter.instantiateByKey(props,
                  errorHandlerPrefix,
                  ErrorHandler.class,
                  null);
        if (eh != null) {
              appender.setErrorHandler(eh);
              LogLog.debug("Parsing errorhandler options for \"" + appenderName +"\".");
              parseErrorHandler(eh, errorHandlerPrefix, props, repository);
              final Properties edited = new Properties();
              final String[] keys = new String[] { 
                      errorHandlerPrefix + "." + ROOT_REF,
                      errorHandlerPrefix + "." + LOGGER_REF,
                      errorHandlerPrefix + "." + APPENDER_REF_TAG
              };
              for(Iterator iter = props.entrySet().iterator();iter.hasNext();) {
                  Map.Entry entry = (Map.Entry) iter.next();
                  int i = 0;
                  for(; i < keys.length; i++) {
                      if(keys[i].equals(entry.getKey())) break;
                  }
                  if (i == keys.length) {
                      edited.put(entry.getKey(), entry.getValue());
                  }
              }
              PropertySetter.setProperties(eh, edited, errorHandlerPrefix + ".");
              LogLog.debug("End of errorhandler parsing for \"" + appenderName +"\".");
        }

     }
     //configureOptionHandler((OptionHandler) appender, prefix + ".", props);
     PropertySetter.setProperties(appender, props, prefix + ".");
     LogLog.debug("Parsed \"" + appenderName +"\" options.");
   }
   parseAppenderFilters(props, appenderName, appender);
   registryPut(appender);
   return appender;
 }
项目:daq-eclipse    文件:DOMConfigurator.java   
/**
    Used internally to parse an {@link ErrorHandler} element.
  */
 protected
 void parseErrorHandler(Element element, Appender appender) {
   ErrorHandler eh = (ErrorHandler) OptionConverter.instantiateByClassName(
                                      subst(element.getAttribute(CLASS_ATTR)),
                                      org.apache.log4j.spi.ErrorHandler.class, 
                       null);

   if(eh != null) {
     eh.setAppender(appender);

     PropertySetter propSetter = new PropertySetter(eh);
     NodeList children = element.getChildNodes();
     final int length   = children.getLength();

     for (int loop = 0; loop < length; loop++) {
Node currentNode = children.item(loop);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
  Element currentElement = (Element) currentNode;
  String tagName = currentElement.getTagName();
  if(tagName.equals(PARAM_TAG)) {
           setParameter(currentElement, propSetter);
  } else if(tagName.equals(APPENDER_REF_TAG)) {
    eh.setBackupAppender(findAppenderByReference(currentElement));
  } else if(tagName.equals(LOGGER_REF)) {
    String loggerName = currentElement.getAttribute(REF_ATTR);      
    Logger logger = (catFactory == null) ? repository.getLogger(loggerName)
               : repository.getLogger(loggerName, catFactory);
    eh.setLogger(logger);
  } else if(tagName.equals(ROOT_REF)) {
    Logger root = repository.getRootLogger();
    eh.setLogger(root);
  } else {
         quietParseUnrecognizedElement(eh, currentElement, props);
     }
}
     }
     propSetter.activate();
     appender.setErrorHandler(eh);
   }
 }
项目:Lucee4    文件:TaskAppender.java   
@Override
public ErrorHandler getErrorHandler() {
    return appender.getErrorHandler();
}