当前位置: 首页>>代码示例>>Java>>正文


Java LogbackException类代码示例

本文整理汇总了Java中ch.qos.logback.core.LogbackException的典型用法代码示例。如果您正苦于以下问题:Java LogbackException类的具体用法?Java LogbackException怎么用?Java LogbackException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LogbackException类属于ch.qos.logback.core包,在下文中一共展示了LogbackException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: autoConfig

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
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);
        }
    }

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:22,代码来源:KonkerContextInitializer.java

示例2: configureByResource

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
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");
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:24,代码来源:ContextInitializer.java

示例3: autoConfig

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
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);
    }
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:21,代码来源:ContextInitializer.java

示例4: buildLoggerContext

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:20,代码来源:DynamicLogback918Logger.java

示例5: doAppend

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
@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");
      }
    });
  }

}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:17,代码来源:Console.java

示例6: lazyClient

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
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();
    }
 
开发者ID:Zensight,项目名称:natural-log,代码行数:23,代码来源:RiemannAppender.java

示例7: createManager

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:jopecko,项目名称:logback-flume-ng,代码行数:24,代码来源:FlumeEmbeddedManager.java

示例8: setBody

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:jopecko,项目名称:logback-flume-ng,代码行数:25,代码来源:FlumeEvent.java

示例9: doAppend

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
@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);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:13,代码来源:KafkaLogbackAppender.java

示例10: configureByResource

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
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);


    }
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:16,代码来源:KonkerContextInitializer.java

示例11: shouldThrowExceptionIfUnexpectedConfigurationFileExtension

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
@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
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:14,代码来源:ContextInitializerTest.java

示例12: doAppend

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
/**
 * 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);
		}
	}
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:42,代码来源:Log.java

示例13: doAppend

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
@Override
public void doAppend(ILoggingEvent iLoggingEvent) throws LogbackException {
  loggedEvents.add(iLoggingEvent);
}
 
开发者ID:mustaine,项目名称:logcapture,代码行数:5,代码来源:StubAppender.java

示例14: doAppend

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
@Override
public void doAppend(E e) throws LogbackException {
    logs.add(e);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:5,代码来源:FifoLogbackAppender.java

示例15: doAppend

import ch.qos.logback.core.LogbackException; //导入依赖的package包/类
@Override
public void doAppend(final ILoggingEvent loggingEvent) throws LogbackException {
    logs.add(loggingEvent.getFormattedMessage());
}
 
开发者ID:marccarre,项目名称:commons-testing,代码行数:5,代码来源:LogbackCollectionAppender.java


注:本文中的ch.qos.logback.core.LogbackException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。