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.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()); } } }
/** * When system exit,this method will be called to close resources * * @param timeout * @param timeUnit * @return */ public boolean stop(long timeout, TimeUnit timeUnit) { this.setStopping(); try { ProducerInstance.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; }
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()); } } }
/** * 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; }
/** * The handler must be set before the appender is started. * @param handler The ErrorHandler to use. */ @Override public void setHandler(final ErrorHandler handler) { if (handler == null) { LOGGER.error("The handler cannot be set to null"); } if (isStarted()) { LOGGER.error("The handler cannot be changed once the appender is started"); return; } this.handler = handler; }
/** * The handler must be set before the appender is started. * * @param handler The ErrorHandler to use. */ @Override public void setHandler(final ErrorHandler handler) { if (handler == null) { LOGGER.error("The handler cannot be set to null"); } if (isStarted()) { LOGGER.error("The handler cannot be changed once the appender is started"); return; } this.handler = handler; }
@Override public ErrorHandler getHandler() { return errorHandler; }
@Override public void setHandler(ErrorHandler errorHandler) { this.errorHandler = errorHandler; }
@Override public ErrorHandler getHandler() { throw new UnsupportedOperationException("Not implemented"); }
@Override public void setHandler(final ErrorHandler errorHandler) { throw new UnsupportedOperationException("Not implemented"); }
/** * Returns the ErrorHandler, if any. * @return The ErrorHandler. */ @Override public ErrorHandler getHandler() { return handler; }
@Override public ErrorHandler getHandler() { return null; }
@Override public void setHandler(ErrorHandler errorHandler) { }
/** * Returns the ErrorHandler, if any. * * @return The ErrorHandler. */ @Override public ErrorHandler getHandler() { return handler; }