Tabnine Logo
ErrorHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
ErrorHandler
in
org.apache.logging.log4j.core

Best Java code snippets using org.apache.logging.log4j.core.ErrorHandler (Showing top 15 results out of 315)

origin: apache/rocketmq

protected RocketmqLog4j2Appender(String name, Filter filter, Layout<? extends Serializable> layout,
  boolean ignoreExceptions, String nameServerAddress, String producerGroup,
  String topic, String tag) {
  super(name, filter, layout, ignoreExceptions);
  this.producer = producer;
  this.topic = topic;
  this.tag = tag;
  this.nameServerAddress = nameServerAddress;
  this.producerGroup = producerGroup;
  try {
    this.producer = ProducerInstance.getProducerInstance().getInstance(this.nameServerAddress, this.producerGroup);
  } catch (Exception e) {
    ErrorHandler handler = this.getHandler();
    if (handler != null) {
      handler.error("Starting RocketmqLog4j2Appender [" + this.getName()
        + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
    }
  }
}
origin: apache/rocketmq

/**
 * Info,error,warn,callback method implementation
 */
public void append(LogEvent event) {
  if (null == producer) {
    return;
  }
  byte[] data = this.getLayout().toByteArray(event);
  try {
    Message msg = new Message(topic, tag, data);
    msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOG4J2_APPENDER);
    //Send message and do not wait for the ack from the message broker.
    producer.sendOneway(msg);
  } catch (Exception e) {
    ErrorHandler handler = this.getHandler();
    if (handler != null) {
      String msg = new String(data);
      handler.error("Could not send message in RocketmqLog4j2Appender [" + this.getName() + "].Message is : " + msg, e);
    }
  }
}
origin: apache/rocketmq

/**
 * When system exit,this method will be called to close resources
 */
public boolean stop(long timeout, TimeUnit timeUnit) {
  this.setStopping();
  try {
    ProducerInstance.getProducerInstance().removeAndClose(this.nameServerAddress, this.producerGroup);
  } catch (Exception e) {
    ErrorHandler handler = this.getHandler();
    if (handler != null) {
      handler.error("Closeing RocketmqLog4j2Appender [" + this.getName()
        + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
    }
  }
  boolean stopped = super.stop(timeout, timeUnit, false);
  this.setStopped();
  return stopped;
}
origin: didi/DDMQ

protected RocketmqLog4j2Appender(String name, Filter filter, Layout<? extends Serializable> layout,
  boolean ignoreExceptions, String nameServerAddress, String producerGroup,
  String topic, String tag) {
  super(name, filter, layout, ignoreExceptions);
  this.producer = producer;
  this.topic = topic;
  this.tag = tag;
  this.nameServerAddress = nameServerAddress;
  this.producerGroup = producerGroup;
  try {
    this.producer = ProducerInstance.getProducerInstance().getInstance(this.nameServerAddress, this.producerGroup);
  } catch (Exception e) {
    ErrorHandler handler = this.getHandler();
    if (handler != null) {
      handler.error("Starting RocketmqLog4j2Appender [" + this.getName()
        + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
    }
  }
}
origin: didi/DDMQ

/**
 * Info,error,warn,callback method implementation
 */
public void append(LogEvent event) {
  if (null == producer) {
    return;
  }
  byte[] data = this.getLayout().toByteArray(event);
  try {
    Message msg = new Message(topic, tag, data);
    msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOG4J2_APPENDER);
    //Send message and do not wait for the ack from the message broker.
    producer.sendOneway(msg);
  } catch (Exception e) {
    ErrorHandler handler = this.getHandler();
    if (handler != null) {
      String msg = new String(data);
      handler.error("Could not send message in RocketmqLog4j2Appender [" + this.getName() + "].Message is : " + msg, e);
    }
  }
}
origin: didi/DDMQ

/**
 * When system exit,this method will be called to close resources
 */
public boolean stop(long timeout, TimeUnit timeUnit) {
  this.setStopping();
  try {
    ProducerInstance.getProducerInstance().removeAndClose(this.nameServerAddress, this.producerGroup);
  } catch (Exception e) {
    ErrorHandler handler = this.getHandler();
    if (handler != null) {
      handler.error("Closeing RocketmqLog4j2Appender [" + this.getName()
        + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
    }
  }
  boolean stopped = super.stop(timeout, timeUnit, false);
  this.setStopped();
  return stopped;
}
origin: ops4j/org.ops4j.pax.logging

/**
 * Handle an error with a message using the {@link ErrorHandler} configured for this Appender.
 * 
 * @param msg The message.
 */
public void error(final String msg) {
  handler.error(msg);
}
origin: ops4j/org.ops4j.pax.logging

/**
 * Handle an error with a message, exception, and a logging event, using the {@link ErrorHandler} configured for
 * this Appender.
 * 
 * @param msg The message.
 * @param event The LogEvent.
 * @param t The Throwable.
 */
public void error(final String msg, final LogEvent event, final Throwable t) {
  handler.error(msg, event, t);
}
origin: ops4j/org.ops4j.pax.logging

/**
 * Handle an error with a message and an exception using the {@link ErrorHandler} configured for this Appender.
 * 
 * @param msg The message.
 * @param t The Throwable.
 */
public void error(final String msg, final Throwable t) {
  handler.error(msg, t);
}
origin: ops4j/org.ops4j.pax.logging

private String appenderErrorHandlerMessage(final String prefix) {
  final String result = createErrorMsg(prefix);
  appender.getHandler().error(result);
  return result;
}
origin: com.vlkan.log4j2/log4j2-redis-appender

private synchronized void changeState(State initialState, State transitionState, State finalState, Runnable body) {
  logger.debug("expecting state: %s", initialState);
  if (initialState != state) {
    String message = String.format("expecting: %s, found: %s", initialState, state);
    errorHandler.error(message);
    throw new IllegalStateException(message);
  }
  logger.debug("transitioning state: %s", transitionState);
  state = transitionState;
  try {
    if (body != null) {
      body.run();
    }
    logger.debug("finalizing state: %s", finalState);
    state = finalState;
  } catch (Exception error) {
    String message = String.format(
        "state change failure (initialState=%s, transitionState=%s, finalState=%s)",
        initialState, transitionState, finalState);
    if (debugEnabled) {
      logger.debug("%s: %s", message, error.getMessage());
      error.printStackTrace();
    }
    errorHandler.error(message, error);
    throw new RuntimeException(message, error);
  }
}
origin: ops4j/org.ops4j.pax.logging

private void handleAppenderError(final RuntimeException ex) {
  appender.getHandler().error(createErrorMsg("An exception occurred processing Appender "), ex);
  if (!appender.ignoreExceptions()) {
    throw ex;
  }
}
origin: spring-projects/spring-amqp

  getHandler().error("Could not send log message " + logEvent.getMessage()
      + " after " + this.manager.maxSenderRetries + " retries", logEvent, e);
getHandler().error("Could not send log message " + logEvent.getMessage(), logEvent, e);
origin: org.springframework.amqp/spring-rabbit

  getHandler().error("Could not send log message " + logEvent.getMessage()
      + " after " + this.manager.maxSenderRetries + " retries", logEvent, e);
getHandler().error("Could not send log message " + logEvent.getMessage(), logEvent, e);
origin: org.dblock.log4jna/log4jna-api

/** 
 * {@inheritDoc}
 */
public void append(LogEvent event) {
  if (_handle == null) {
    registerEventSource();
  }
  String s = new String(getLayout().toByteArray(event));
  final int messageID = 0x1000;
  String[] buffer = { s };
  if (Advapi32.INSTANCE.ReportEvent(_handle, getEventLogType(event.getLevel()),
      getEventLogCategory(event.getLevel()), messageID, null, buffer.length, 0, buffer, null) == false) {
    Exception e = new Win32Exception(Kernel32.INSTANCE.GetLastError());
    getHandler().error("Failed to report event [" + s + "].", event, e);
  }
}
org.apache.logging.log4j.coreErrorHandler

Javadoc

Appenders may delegate their error handling to ErrorHandlers. TODO if the appender interface is simplified, then error handling could just be done by wrapping a nested appender. (RG) Please look at DefaultErrorHandler. It's purpose is to make sure the console or error log isn't flooded with messages. I'm still considering the Appender refactoring.

Most used methods

  • error

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • findViewById (Activity)
  • onRequestPermissionsResult (Fragment)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Reference (javax.naming)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now