本文整理汇总了Java中ch.qos.logback.core.status.ErrorStatus类的典型用法代码示例。如果您正苦于以下问题:Java ErrorStatus类的具体用法?Java ErrorStatus怎么用?Java ErrorStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorStatus类属于ch.qos.logback.core.status包,在下文中一共展示了ErrorStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: multiplicityWarning
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
private void multiplicityWarning(String resourceName, ClassLoader classLoader) {
Set urlSet = null;
StatusManager sm = this.loggerContext.getStatusManager();
try {
urlSet = Loader.getResourceOccurrenceCount(resourceName, classLoader);
} catch (IOException var7) {
sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]", this.loggerContext, var7));
}
if (urlSet != null && urlSet.size() > 1) {
sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.", this.loggerContext));
Iterator i$ = urlSet.iterator();
while (i$.hasNext()) {
URL url = (URL) i$.next();
sm.add(new WarnStatus("Resource [" + resourceName + "] occurs at [" + url.toString() + "]", this.loggerContext));
}
}
}
示例2: start
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
/**
* Options are activated and become effective only after calling this method.
*/
public void start() {
int errors = 0;
if (this.layout == null) {
addStatus(new ErrorStatus("No layout set for the RocketmqLogbackAppender named \"" + name + "\".", this));
errors++;
}
if (errors > 0 || !checkEntryConditions()) {
return;
}
try {
producer = ProducerInstance.getInstance(nameServerAddress, producerGroup);
} catch (Exception e) {
addError("Starting RocketmqLogbackAppender [" + this.getName()
+ "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
}
if (producer != null) {
super.start();
}
}
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:25,代码来源:RocketmqLogbackAppender.java
示例3: start
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
/**
* Checks that the required parameters are set and if everything is in
* order, activates this appender.
*/
@Override
public void start() {
boolean error = false;
if (this.encoder == null) {
error = true;
addStatus(
new ErrorStatus(
"No encoder set for the appender named [" + name + "].",
this
)
);
}
if (!error) {
super.start();
}
}
示例4: start
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
/**
* Options are activated and become effective only after calling this method.
*/
public void start() {
int errors = 0;
if (this.layout == null) {
addStatus(new ErrorStatus("No layout set for the RocketmqLogbackAppender named \"" + name + "\".", this));
errors++;
}
if (errors > 0 || !checkEntryConditions()) {
return;
}
try {
producer = ProducerInstance.getProducerInstance().getInstance(nameServerAddress, producerGroup);
} catch (Exception e) {
addError("Starting RocketmqLogbackAppender [" + this.getName()
+ "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
}
if (producer != null) {
super.start();
}
}
示例5: start
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
@Override
public void start() {
int errors = 0;
if (level == null) {
addStatus(new ErrorStatus("No level set for the appender named \"" + name + "\".", this));
errors++;
}
if (endpoint == null) {
addStatus(new ErrorStatus("No endpoint set for the appender named \"" + name + "\".", this));
errors++;
}
if (layout == null) {
addStatus(new ErrorStatus("No layout set for the appender named \"" + name + "\".", this));
errors++;
}
if (errors == 0) {
super.start();
}
}
示例6: start
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
public void start() {
if(pattern == null || pattern.length() == 0) {
addError("Empty or null pattern.");
return;
}
try {
Parser<E> p = new Parser<E>(pattern);
if (getContext() != null) {
p.setContext(getContext());
}
Node t = p.parse();
this.head = p.compile(t, getEffectiveConverterMap());
if (postCompileProcessor != null) {
postCompileProcessor.process(head);
}
ConverterUtil.setContextForConverters(getContext(), head);
ConverterUtil.startConverters(this.head);
super.start();
} catch (ScanException sce) {
StatusManager sm = getContext().getStatusManager();
sm.add(new ErrorStatus("Failed to parse pattern \"" + getPattern()
+ "\".", this, sce));
}
}
示例7: start
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
/**
* 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();
}
}
示例8: subAppend
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
/**
* Actual writing occurs here.
* <p>
* Most subclasses of <code>WriterAppender</code> will need to override this
* method.
*
* @since 0.9.0
*/
protected void subAppend(E event) {
if (!isStarted()) {
return;
}
try {
// this step avoids LBCLASSIC-139
if (event instanceof DeferredProcessingAware) {
((DeferredProcessingAware) event).prepareForDeferredProcessing();
}
// the synchronization prevents the OutputStream from being closed while we
// are writing. It also prevents multiple threads from entering the same
// converter. Converters assume that they are in a synchronized block.
lock.lock();
try {
writeOut(event);
} finally {
lock.unlock();
}
} catch (IOException ioe) {
// as soon as an exception occurs, move to non-started state
// and add a single ErrorStatus to the SM.
this.started = false;
addStatus(new ErrorStatus("IO failure in appender", this, ioe));
}
}
示例9: many
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
@Test
public void many() {
int margin = 300;
int len = MAX_HEADER_COUNT + TAIL_SIZE + margin;
for (int i = 0; i < len; i++) {
bsm.add(new ErrorStatus("" + i, this));
}
List<Status> statusList = bsm.getCopyOfStatusList();
assertNotNull(statusList);
assertEquals(MAX_HEADER_COUNT + TAIL_SIZE, statusList.size());
List<Status> witness = new ArrayList<Status>();
for (int i = 0; i < MAX_HEADER_COUNT; i++) {
witness.add(new ErrorStatus("" + i, this));
}
for (int i = 0; i < TAIL_SIZE; i++) {
witness.add(new ErrorStatus("" + (MAX_HEADER_COUNT + margin + i), this));
}
assertEquals(witness, statusList);
}
示例10: configureByResource
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的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");
}
}
示例11: multiplicityWarning
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
private void multiplicityWarning(String resourceName, ClassLoader classLoader) {
Set<URL> urlSet = null;
StatusManager sm = loggerContext.getStatusManager();
try {
urlSet = Loader.getResourceOccurrenceCount(resourceName, classLoader);
} catch (IOException e) {
sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]",
loggerContext, e));
}
if (urlSet != null && urlSet.size() > 1) {
sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.",
loggerContext));
for (URL url : urlSet) {
sm.add(new WarnStatus("Resource [" + resourceName + "] occurs at [" + url.toString() + "]",
loggerContext));
}
}
}
示例12: zeroNesting
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
@Test
public void zeroNesting() throws JoranException {
configure(SIFT_FOLDER_PREFIX + "zeroNesting.xml");
logger.debug("hello");
logger.debug("hello");
logger.debug("hello");
logger.debug("hello");
logger.debug("hello");
SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT");
Appender<ILoggingEvent> appender = getAppenderTracker().find("zeroDefault");
assertNotNull(appender);
NOPAppender<ILoggingEvent> nopa = (NOPAppender<ILoggingEvent>) appender;
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
statusChecker.assertContainsMatch(ErrorStatus.ERROR, "No nested appenders found");
}
示例13: stop
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
@Override
public synchronized void stop() {
if (!isStarted()) {
return;
}
try {
this.encoder.close();
// no need to restore System.out (due to buffering, better not to do that)
} catch (final IOException ex) {
addStatus(new ErrorStatus("Failed to write footer for appender named \""
+ this.name + "\".", this, ex));
} finally {
super.stop();
}
}
示例14: append
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
@Override
protected synchronized void append(final E event) {
if (!isStarted()) {
return;
}
try {
if (event instanceof DeferredProcessingAware) {
((DeferredProcessingAware) event).prepareForDeferredProcessing();
}
this.encoder.doEncode(event);
} catch (final IOException ex) {
stop();
addStatus(new ErrorStatus("IO failure in appender named \"" + this.name + "\".",
this, ex));
}
}
示例15: subAppend
import ch.qos.logback.core.status.ErrorStatus; //导入依赖的package包/类
/**
*
* @param eventObject
*/
private void subAppend(ILoggingEvent eventObject) {
if (!isStarted()) {
return;
}
try {
// this step avoids LBCLASSIC-139
if (eventObject instanceof DeferredProcessingAware) {
((DeferredProcessingAware) eventObject).prepareForDeferredProcessing();
}
this.encoder.doEncode(eventObject);
} catch (IOException ioe) {
this.started = false;
addStatus(new ErrorStatus("IO failure in appender", this, ioe));
}
}