Search in sources :

Example 1 with LogbackException

use of ch.qos.logback.core.LogbackException in project cdap by caskdata.

the class CDAPLogAppender method doAppend.

@Override
public void doAppend(ILoggingEvent eventObject) throws LogbackException {
    if (logFileManager == null) {
        return;
    }
    long timestamp = eventObject.getTimeStamp();
    try {
        // logic from AppenderBase
        if (!this.started) {
            addStatus(new WarnStatus("Attempted to append to non started appender [" + name + "].", this));
            return;
        }
        // logic from AppenderBase
        if (getFilterChainDecision(eventObject) == FilterReply.DENY) {
            return;
        }
        LogPathIdentifier logPathIdentifier = getLoggingPath(eventObject.getMDCPropertyMap());
        LogFileOutputStream outputStream = logFileManager.getLogFileOutputStream(logPathIdentifier, timestamp);
        outputStream.append(eventObject);
    } catch (IllegalArgumentException iae) {
        // this shouldn't happen
        LOG.error("Unrecognized context ", iae);
    } catch (IOException ioe) {
        throw new LogbackException("Exception during append", ioe);
    }
}
Also used : WarnStatus(ch.qos.logback.core.status.WarnStatus) IOException(java.io.IOException) LogbackException(ch.qos.logback.core.LogbackException)

Example 2 with LogbackException

use of ch.qos.logback.core.LogbackException in project cdap by caskdata.

the class RollingLocationLogAppender method doAppend.

@Override
public void doAppend(ILoggingEvent eventObject) throws LogbackException {
    try {
        // logic from AppenderBase
        if (!this.started) {
            LOG.warn("Attempted to append to non started appender {}", this.getName());
            return;
        }
        // logic from AppenderBase
        if (getFilterChainDecision(eventObject) == FilterReply.DENY) {
            return;
        }
        String namespaceId = eventObject.getMDCPropertyMap().get(LocationManager.TAG_NAMESPACE_ID);
        if (namespaceId != null && !namespaceId.equals(NamespaceId.SYSTEM.getNamespace())) {
            LocationIdentifier logLocationIdentifier = locationManager.getLocationIdentifier(eventObject.getMDCPropertyMap());
            rollover(logLocationIdentifier, eventObject);
            OutputStream locationOutputStream = locationManager.getLocationOutputStream(logLocationIdentifier, filePath);
            setOutputStream(locationOutputStream);
            writeOut(eventObject);
        }
    } catch (IllegalArgumentException iae) {
        // this shouldn't happen
        LOG.error("Unrecognized context ", iae);
    } catch (IOException ioe) {
        throw new LogbackException("Exception while appending event. ", ioe);
    } catch (RolloverFailure rolloverFailure) {
        throw new LogbackException("Exception while rolling over. ", rolloverFailure);
    }
}
Also used : RolloverFailure(ch.qos.logback.core.rolling.RolloverFailure) OutputStream(java.io.OutputStream) IOException(java.io.IOException) LogbackException(ch.qos.logback.core.LogbackException)

Aggregations

LogbackException (ch.qos.logback.core.LogbackException)2 IOException (java.io.IOException)2 RolloverFailure (ch.qos.logback.core.rolling.RolloverFailure)1 WarnStatus (ch.qos.logback.core.status.WarnStatus)1 OutputStream (java.io.OutputStream)1