Java 类ch.qos.logback.core.LogbackException 实例源码

项目:konker-platform    文件:KonkerContextInitializer.java   
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);
        }
    }

}
项目:bartleby    文件:ContextInitializer.java   
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");
  }
}
项目:bartleby    文件:ContextInitializer.java   
public void autoConfig() throws JoranException {
  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.configure(loggerContext);
    }
  }
}
项目:tddl5    文件:DynamicLogback918Logger.java   
public static LoggerContext buildLoggerContext(Map<String, String> props) {
    if (loggerContext == null) {
        ILoggerFactory lcObject = LoggerFactory.getILoggerFactory();

        if (!(lcObject instanceof LoggerContext)) {
            throw new LogbackException("Expected LOGBACK binding with SLF4J, but another log system has taken the place: "
                                       + lcObject.getClass().getSimpleName());
        }

        loggerContext = (LoggerContext) lcObject;
        if (props != null) {
            for (Map.Entry<String, String> entry : props.entrySet()) {
                loggerContext.putProperty(entry.getKey(), entry.getValue());
            }
        }
    }

    return loggerContext;
}
项目:myrobotlab    文件:Console.java   
@Override
public void doAppend(ILoggingEvent loggingEvent) throws LogbackException {
  // append(loggingEvent);
  if (logging) {
    final String msg = String.format("[%s] %s", loggingEvent.getThreadName(), loggingEvent.toString()).trim();

    // textarea not threadsafe, needs invokelater
    EventQueue.invokeLater(new Runnable() {
      // @Override
      public void run() {
        textArea.append(msg + "\n");
      }
    });
  }

}
项目:natural-log    文件:RiemannAppender.java   
private RiemannClient lazyClient() {

        if (getRiemannClient() == null) {

            if (riemannHost == null) {
                throw new LogbackException("riemannHost must be set");
            }

            if (riemannPort <= 0) {
                throw new LogbackException("riemannPort must be set");
            }

            try {
                setRiemannClient(RiemannClient.tcp(riemannHost, riemannPort));

            } catch (IOException ex) {
                throw new LogbackException("Can't connect to " + riemannHost + ":" + riemannPort, ex);
            }
        }

        return getRiemannClient();
    }
项目:logback-flume-ng    文件:FlumeEmbeddedManager.java   
/**
 * Create the FlumeAvroManager.
 * @param name The name of the entity to manage.
 * @param data The data required to create the entity.
 * @return The FlumeAvroManager.
 */
@Override
public FlumeEmbeddedManager createManager(final String name, final FactoryData data) {
  try {
    final DefaultLogicalNodeManager nodeManager = new DefaultLogicalNodeManager();
    final Properties props = createProperties(data.name, data.agents, data.batchSize, data.dataDir);
    final FlumeConfigurationBuilder builder = new FlumeConfigurationBuilder();
    final NodeConfiguration conf = builder.load(data.name, props, nodeManager);

    final FlumeNode node = new FlumeNode(nodeManager, nodeManager, conf);

    node.start();

    return new FlumeEmbeddedManager(name, data.name, node);
  } catch (final Exception ex) {
    throw new LogbackException("Could not create FlumeEmbeddedManager", ex);
  }
}
项目:logback-flume-ng    文件:FlumeEvent.java   
/**
 * Set the body in the event.
 * @param body The body to add to the event.
 */
@Override
public void setBody(final byte[] body) {
  if (body == null || body.length == 0) {
    super.setBody(new byte[0]);
    return;
  }
  if (compress) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
      final GZIPOutputStream os = new GZIPOutputStream(baos);
      os.write(body);
      os.close();
    } catch (final IOException ioe) {
      throw new LogbackException("Unable to compress message", ioe);
    }
    super.setBody(baos.toByteArray());
  } else {
    super.setBody(body);
  }
}
项目:stroom-query    文件:KafkaLogbackAppender.java   
@Override
public void doAppend(E e) throws LogbackException {
    final ProducerRecord<String, byte[]> record =
            new ProducerRecord<>(
                    topic,
                    PARTITION,
                    System.currentTimeMillis(),
                    KEY,
                    e.toString().getBytes(Charset.defaultCharset()));

    producer.send(record);
}
项目:konker-platform    文件:KonkerContextInitializer.java   
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.toString() + "]. Should be either .groovy or .xml");
        }
        JoranConfigurator configurator1 = new JoranConfigurator();
        configurator1.setContext(this.loggerContext);
        configurator1.doConfigure(url);


    }
}
项目:bartleby    文件:ContextInitializerTest.java   
@Test
public void shouldThrowExceptionIfUnexpectedConfigurationFileExtension() throws JoranException {
  LoggerContext loggerContext = new LoggerContext();
  ContextInitializer initializer = new ContextInitializer(loggerContext);

  URL configurationFileUrl = Loader.getResource("README.txt", Thread.currentThread().getContextClassLoader());
  try {
    initializer.configureByResource(configurationFileUrl);
    fail("Should throw LogbackException");
  } catch (LogbackException expectedException) {
    // pass
  }
}
项目:myrobotlab    文件:Log.java   
/**
 * Main interface through which slf4j sends logging.
 * This method in turn publishes the events to a MRL publishLogEvent topic.
 */
@Override
public void doAppend(ILoggingEvent event) throws LogbackException {
    // event.getFormattedMessage();
    Message msg = Message.createMessage(this, null, "onLogEvent", new Object[] { String.format("[%s] %s", event.getThreadName(), event.toString()) });
    msg.sendingMethod = "publishLogEvent";
    msg.sender = getName();
    Object[] param = new Object[] { msg };

    // Object[] param = new Object[] { String.format("[%s] %s",
    // arg0.getThreadName(), arg0.toString()) };

    if (publishLogEventNotifyList.size() != 0) {
        // get the value for the source method
        ArrayList<MRLListener> subList = publishLogEventNotifyList.get("publishLogEvent");
        for (int i = 0; i < subList.size(); ++i) {
            MRLListener listener = subList.get(i);

            ServiceInterface si = Runtime.getService(listener.callbackName);
            Class<?> c = si.getClass();
            try {
                Method meth = c.getMethod(listener.callbackMethod, new Class<?>[] { Message.class });
                // TODO: what to do with this returned object?
                // Object retobj = meth.invoke(si, param);
                meth.invoke(si, param);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            // send(msg);

            // must make new for internal queues
            // otherwise you'll change the name on
            // existing enqueued messages
            // msg = new Message(msg);
        }
    }
}
项目:logcapture    文件:StubAppender.java   
@Override
public void doAppend(ILoggingEvent iLoggingEvent) throws LogbackException {
  loggedEvents.add(iLoggingEvent);
}
项目:stroom-query    文件:FifoLogbackAppender.java   
@Override
public void doAppend(E e) throws LogbackException {
    logs.add(e);
}
项目:commons-testing    文件:LogbackCollectionAppender.java   
@Override
public void doAppend(final ILoggingEvent loggingEvent) throws LogbackException {
    logs.add(loggingEvent.getFormattedMessage());
}