@Override public void start() { if (!aai.iteratorForAppenders().hasNext()) { addWarn("No appender was attached to " + getClass().getSimpleName() + '.'); } if (exporter == null) { exporter = builder.build(); } super.start(); }
@Override public void stop() { try { aai.detachAndStopAllAppenders(); } finally { super.stop(); } }
addStatus(new WarnStatus( "Attempted to append to non started appender [" + name + "].", this)); if (getFilterChainDecision(eventObject) == FilterReply.DENY) { return; this.append(eventObject); addError("Appender [" + name + "] failed to append.", e);
/** Initialize and configure the cloud logging service. */ @Override public synchronized void start() { if (isStarted()) { return; } MonitoredResource resource = getMonitoredResource(getProjectId()); defaultWriteOptions = new WriteOption[] {WriteOption.logName(getLogName()), WriteOption.resource(resource)}; getLogging().setFlushSeverity(severityFor(getFlushLevel())); loggingEnhancers = new ArrayList<>(); List<LoggingEnhancer> resourceEnhancers = MonitoredResourceUtil.getResourceEnhancers(); loggingEnhancers.addAll(resourceEnhancers); loggingEnhancers.addAll(getLoggingEnhancers()); loggingEventEnhancers = new ArrayList<>(); loggingEventEnhancers.addAll(getLoggingEventEnhancers()); super.start(); }
@Override public synchronized void stop() { if (logging != null) { try { logging.close(); } catch (Exception ex) { // ignore } } logging = null; super.stop(); }
addStatus(new WarnStatus( "Attempted to append to non started appender [" + name + "].", this)); if (getFilterChainDecision(eventObject) == FilterReply.DENY) { return; this.append(eventObject); addError("Appender [" + name + "] failed to append.", e);
@Override public void start() { super.start(); }
@Override public void stop() { super.stop(); } }
public void doAppend(E eventObject) { // WARNING: The guard check MUST be the first statement in the // doAppend() method. // prevent re-entry. if (Boolean.TRUE.equals(guard.get())) { return; } try { guard.set(Boolean.TRUE); if (!this.started) { if (statusRepeatCount++ < ALLOWED_REPEATS) { addStatus(new WarnStatus("Attempted to append to non started appender [" + name + "].", this)); } return; } if (getFilterChainDecision(eventObject) == FilterReply.DENY) { return; } // ok, we now invoke derived class' implementation of append this.append(eventObject); } catch (Exception e) { if (exceptionCount++ < ALLOWED_REPEATS) { addError("Appender [" + name + "] failed to append.", e); } } finally { guard.set(Boolean.FALSE); } }
@Override public void start() { if (connectionSource == null) { throw new IllegalStateException( "DBAppender cannot function without a connection source"); } sqlDialect = DBUtil .getDialectFromCode(connectionSource.getSQLDialectCode()); if (getGeneratedKeysMethod() != null) { cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys(); } else { cnxSupportsGetGeneratedKeys = false; } cnxSupportsBatchUpdates = connectionSource.supportsBatchUpdates(); if (!cnxSupportsGetGeneratedKeys && (sqlDialect == null)) { throw new IllegalStateException( "DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect"); } // all nice and dandy on the eastern front super.start(); }
/** * Stop this appender instance. The underlying stream or writer is also * closed. * * <p> * Stopped appenders cannot be reused. */ public void stop() { lock.lock(); try { closeOutputStream(); super.stop(); } finally { lock.unlock(); } }
public void doAppend(E eventObject) { // WARNING: The guard check MUST be the first statement in the // doAppend() method. // prevent re-entry. if (guard.get()) { return; } try { guard.set(true); if (!this.started) { if (statusRepeatCount++ < ALLOWED_REPEATS) { addStatus(new WarnStatus( "Attempted to append to non started appender [" + name + "].", this)); } return; } if (getFilterChainDecision(eventObject) == FilterReply.DENY) { return; } // ok, we now invoke derived class' implementation of append this.append(eventObject); } catch (Exception e) { if (exceptionCount++ < ALLOWED_REPEATS) { addError("Appender [" + name + "] failed to append.", e); } } finally { guard.set(false); } }
/** * Checks that requires parameters are set and if everything is in order, * activates this appender. */ public void start() { int errors = 0; if (this.encoder == null) { addStatus(new ErrorStatus("No encoder set for the appender named \"" + name + "\".", this)); errors++; } if (this.outputStream == null) { addStatus(new ErrorStatus( "No output stream set for the appender named \"" + name + "\".", this)); errors++; } // only error free appenders should be activated if (errors == 0) { super.start(); } }
@Override public void stop() { if (!isStarted()) return; // mark this appender as stopped so that Worker can also processPriorToRemoval if it is invoking aii.appendLoopOnAppenders // and sub-appenders consume the interruption super.stop(); // interrupt the worker thread so that it can terminate. Note that the interruption can be consumed // by sub-appenders worker.interrupt(); try { worker.join(1000); } catch (InterruptedException e) { addError("Failed to join worker thread", e); } }
public void doAppend(E eventObject) { // WARNING: The guard check MUST be the first statement in the // doAppend() method. // prevent re-entry. if (Boolean.TRUE.equals(guard.get())) { return; } try { guard.set(Boolean.TRUE); if (!this.started) { if (statusRepeatCount++ < ALLOWED_REPEATS) { addStatus(new WarnStatus("Attempted to append to non started appender [" + name + "].", this)); } return; } if (getFilterChainDecision(eventObject) == FilterReply.DENY) { return; } // ok, we now invoke derived class' implementation of append this.append(eventObject); } catch (Exception e) { if (exceptionCount++ < ALLOWED_REPEATS) { addError("Appender [" + name + "] failed to append.", e); } } finally { guard.set(Boolean.FALSE); } }
@Override public void start() { if (appenderCount == 0) { addError("No attached appenders found."); return; } if (queueSize < 1) { addError("Invalid queue size [" + queueSize + "]"); return; } blockingQueue = new ArrayBlockingQueue<E>(queueSize); if (discardingThreshold == UNDEFINED) discardingThreshold = queueSize / 5; addInfo("Setting discardingThreshold to " + discardingThreshold); worker.setDaemon(true); worker.setName("AsyncAppender-Worker-" + worker.getName()); // make sure this instance is marked as "started" before staring the worker Thread super.start(); worker.start(); }
@Override public void stop() { super.stop(); } }
public void doAppend(E eventObject) { // WARNING: The guard check MUST be the first statement in the // doAppend() method. // prevent re-entry. if (Boolean.TRUE.equals(guard.get())) { return; } try { guard.set(Boolean.TRUE); if (!this.started) { if (statusRepeatCount++ < ALLOWED_REPEATS) { addStatus(new WarnStatus("Attempted to append to non started appender [" + name + "].", this)); } return; } if (getFilterChainDecision(eventObject) == FilterReply.DENY) { return; } // ok, we now invoke derived class' implementation of append this.append(eventObject); } catch (Exception e) { if (exceptionCount++ < ALLOWED_REPEATS) { addError("Appender [" + name + "] failed to append.", e); } } finally { guard.set(Boolean.FALSE); } }
@Override public void start() { super.start(); }
@Override public void stop() { super.stop(); } }