ch.qos.logback.core.LogbackException Java Examples

The following examples show how to use ch.qos.logback.core.LogbackException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuditableLogbackThriftLogger.java    From singer with Apache License 2.0 6 votes vote down vote up
private void append(byte[] partitionKey, byte[] message, long timeNanos,
                            LoggingAuditHeaders headers) throws LogbackException {
    LogMessage logMessage = new LogMessage()
        .setTimestampInNanos(timeNanos).setMessage(message);

    if(this.enableLoggingAudit && headers != null) {
      logMessage.setLoggingAuditHeaders(headers);
      OpenTsdbMetricConverter.incr(AUDIT_THRIFT_LOGGER_HEADERS_ADDED_TO_LOG_MESSAGE_COUNT,
          "topic=" + topic, "host=" + HOST_NAME);
    }
    super.append(logMessage, partitionKey);
    if (this.enableLoggingAudit && headers != null && AuditableLogbackThriftLoggerFactory.getLoggingAuditClient() != null) {
        AuditableLogbackThriftLoggerFactory.getLoggingAuditClient().audit(this.topic, headers, true,
            System.currentTimeMillis());
        OpenTsdbMetricConverter.incr(AUDIT_THRIFT_LOGGER_AUDITED_MESSAGE_COUNT,
            "topic=" + topic, "host=" + HOST_NAME);
    }
}
 
Example #2
Source File: ContextInitializer.java    From stategen with GNU Affero General Public License v3.0 6 votes vote down vote up
public void configureByResource(URL url) throws JoranException {
    if (url == null) {
        throw new IllegalArgumentException("URL argument cannot be null");
    }
    final String urlString = url.toString();
    if (urlString.endsWith("groovy")) {
        if (EnvUtil.isGroovyAvailable()) {
            // avoid directly referring to GafferConfigurator so as to avoid
            // loading groovy.lang.GroovyObject . See also http://jira.qos.ch/browse/LBCLASSIC-214
            GafferUtil.runGafferConfiguratorOn(loggerContext, this, url);
        } else {
            StatusManager sm = loggerContext.getStatusManager();
            sm.add(new ErrorStatus("Groovy classes are not available on the class path. ABORTING INITIALIZATION.", loggerContext));
        }
    } else if (urlString.endsWith("xml")) {
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(loggerContext);
        configurator.doConfigure(url);
    } else {
        throw new LogbackException("Unexpected filename extension of file [" + url.toString() + "]. Should be either .groovy or .xml");
    }
}
 
Example #3
Source File: ContextInitializer.java    From stategen with GNU Affero General Public License v3.0 6 votes vote down vote up
public void autoConfig() throws JoranException ,IOException{
    StatusListenerConfigHelper.installIfAsked(loggerContext);
    URL url = findURLOfDefaultConfigurationFile(true);
    if (url != null) {
        configureByResource(url);
    } else {
        Configurator c = EnvUtil.loadFromServiceLoader(Configurator.class);
        if (c != null) {
            try {
                c.setContext(loggerContext);
                c.configure(loggerContext);
            } catch (Exception e) {
                throw new LogbackException(String.format("Failed to initialize Configurator: %s using ServiceLoader", c != null ? c.getClass()
                                .getCanonicalName() : "null"), e);
            }
        } else {
            BasicConfigurator basicConfigurator = new BasicConfigurator();
            basicConfigurator.setContext(loggerContext);
            basicConfigurator.configure(loggerContext);
        }
    }
}
 
Example #4
Source File: KonkerContextInitializer.java    From konker-platform with Apache License 2.0 6 votes vote down vote up
public void autoConfig() throws JoranException {
    KonkerStatusListenerConfigHelper.installIfAsked(this.loggerContext);
    URL url = this.findURLOfDefaultConfigurationFile(true);
    if (url != null) {
        this.configureByResource(url);
    } else {
        KonkerLoggerConfigurator c = (KonkerLoggerConfigurator)
                EnvUtil.loadFromServiceLoader(KonkerLoggerConfigurator.class);
        if (c != null) {
            try {
                c.setContext(this.loggerContext);
                c.configure(this.loggerContext);
            } catch (Exception var4) {
                throw new LogbackException(String.format("Failed to initialize Configurator: %s using ServiceLoader", new Object[]{c != null ? c.getClass().getCanonicalName() : "null"}), var4);
            }
        } else {
            KonkerLoggerBasicConfigurator.configure(this.loggerContext);
        }
    }

}
 
Example #5
Source File: LogbackThriftLogger.java    From singer with Apache License 2.0 5 votes vote down vote up
/**
 * This method is also called in AuditableLogackThriftLogger to minimize boilerplate code.
 * @param logMessage  logMessage
 * @param partitionKey partition key
 */
protected void append(LogMessage logMessage, byte[] partitionKey) {
  try {
    if (partitionKey != null) {
      logMessage.setKey(partitionKey);
    }
    appender.doAppend(logMessage);
    OpenTsdbMetricConverter.incr(
        THRIFT_LOGGER_COUNT_METRIC, "topic=" + topic, "host=" + HOST_NAME);
  } catch (LogbackException e) {
    OpenTsdbMetricConverter.incr(
        THRIFT_LOGGER_ERROR_LOGBACKEXCEPTION, "topic=" + topic, "host=" + HOST_NAME);
    throw e;
  }
}
 
Example #6
Source File: KonkerContextInitializer.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
public void configureByResource(URL url) throws JoranException {
    if (url == null) {
        throw new IllegalArgumentException("URL argument cannot be null");
    } else {
        String urlString = url.toString();
        if (!urlString.endsWith("xml")) {
            throw new LogbackException("Unexpected filename extension of file [" + url + "]. Should be either .groovy or .xml");
        }
        JoranConfigurator configurator1 = new JoranConfigurator();
        configurator1.setContext(this.loggerContext);
        configurator1.doConfigure(url);


    }
}
 
Example #7
Source File: MetricsLogAppender.java    From pravega with Apache License 2.0 5 votes vote down vote up
@Override
public void doAppend(ILoggingEvent event) throws LogbackException {
    if (event.getLevel() == Level.ERROR) {
        recordEvent(MetricsNames.LOG_ERRORS, event);
    } else if (event.getLevel() == Level.WARN) {
        recordEvent(MetricsNames.LOG_WARNINGS, event);
    }
}
 
Example #8
Source File: Logback1027WorkaroundTurboFilterTest.java    From qpid-broker-j with Apache License 2.0 4 votes vote down vote up
@Override
public void doAppend(final ILoggingEvent event) throws LogbackException
{
    _events.add(event);
}
 
Example #9
Source File: TestLogAppender.java    From specification-arg-resolver with Apache License 2.0 4 votes vote down vote up
@Override
public void doAppend(E event) throws LogbackException {
	TestLogAppender.LOGS.add(event.toString());
}