ch.qos.logback.core.status.ErrorStatus Java Examples
The following examples show how to use
ch.qos.logback.core.status.ErrorStatus.
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: RocketmqLogbackAppender.java From DDMQ with Apache License 2.0 | 6 votes |
/** * 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(); } }
Example #2
Source File: RocketmqLogbackAppender.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
/** * 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(); } }
Example #3
Source File: RocketmqLogbackAppender.java From rocketmq-read with Apache License 2.0 | 6 votes |
/** * 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(); } }
Example #4
Source File: LogbackMemoryAppenderImpl.java From GreenSummer with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void append(ILoggingEvent eventObject) { readLock.lock(); try { String event = patternLayout.doLayout(eventObject); registeredEvents.addFirst(event); if (registeredEvents.size() > size) { registeredEvents.removeLast(); } } catch (Exception e) { addStatus(new ErrorStatus("Failed to store event [" + name + "].", this, e)); } finally { readLock.unlock(); } }
Example #5
Source File: ContextInitializer.java From stategen with GNU Affero General Public License v3.0 | 6 votes |
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 #6
Source File: RocketmqLogbackAppender.java From DDMQ with Apache License 2.0 | 6 votes |
/** * 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(); } }
Example #7
Source File: RocketmqLogbackAppender.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
/** * 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(); } }
Example #8
Source File: KonkerContextInitializer.java From konker-platform with Apache License 2.0 | 6 votes |
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 + ']', this.loggerContext)); } } }
Example #9
Source File: RocketmqLogbackAppender.java From rocketmq with Apache License 2.0 | 6 votes |
/** * 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(); } }
Example #10
Source File: ContextInitializer.java From stategen with GNU Affero General Public License v3.0 | 5 votes |
public URL findURLOfDefaultConfigurationFile(boolean updateStatus) throws IOException { StatusManager sm = loggerContext.getStatusManager(); ClassLoader myClassLoader = Loader.getClassLoaderOfObject(this); URL url = null; url = loadURLFormPropertiesFile(myClassLoader, updateStatus); if (url != null) { sm.add(new InfoStatus("装载文件:"+url, loggerContext) ); return url; } sm.add(new ErrorStatus("从"+application_properties+" 装载文件不成功,不存在!", loggerContext) ); url = findConfigFileURLFromSystemProperties(myClassLoader, updateStatus); if (url != null) { return url; } url = getResource(GROOVY_AUTOCONFIG_FILE, myClassLoader, updateStatus); if (url != null) { return url; } url = getResource(TEST_AUTOCONFIG_FILE, myClassLoader, updateStatus); if (url != null) { return url; } url = getResource(AUTOCONFIG_FILE, myClassLoader, updateStatus); sm.add(new InfoStatus(""+url, loggerContext) ); return url; }
Example #11
Source File: ContextInitializer.java From stategen with GNU Affero General Public License v3.0 | 5 votes |
private void multiplicityWarning(String resourceName, ClassLoader classLoader) { Set<URL> urlSet = null; StatusManager sm = loggerContext.getStatusManager(); try { urlSet = Loader.getResources(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)); } } }
Example #12
Source File: ExceptionConverterTest.java From styx with Apache License 2.0 | 5 votes |
@Test public void errorsIfTargetClassPropertyIsEmpty() throws Exception { ContextBase contextBase = new ContextBase(); StatusManager statusManager = mock(StatusManager.class); contextBase.setStatusManager(statusManager); ExceptionConverter converter = newExceptionConverter(contextBase); converter.getContext() .putProperty(TARGET_CLASSES_PROPERTY_NAME, ""); ILoggingEvent loggingEvent = newErrorLoggingEvent(new TargetClass().blow()); converter.convert(loggingEvent); verify(statusManager).add(any(ErrorStatus.class)); }
Example #13
Source File: KafkaAppenderTest.java From logback-kafka-appender with Apache License 2.0 | 5 votes |
@Test public void testDontStartWithoutTopic() { unit.setTopic(null); unit.start(); assertFalse("isStarted", unit.isStarted()); assertThat(ctx.getStatusManager().getCopyOfStatusList(), hasItem(new ErrorStatus("No topic set for the appender named [\"kafkaAppenderBase\"].", null))); }
Example #14
Source File: KafkaAppenderTest.java From logback-kafka-appender with Apache License 2.0 | 5 votes |
@Test public void testDontStartWithoutBootstrapServers() { unit.getProducerConfig().clear(); unit.start(); assertFalse("isStarted", unit.isStarted()); assertThat(ctx.getStatusManager().getCopyOfStatusList(), hasItem(new ErrorStatus("No \"bootstrap.servers\" set for the appender named [\"kafkaAppenderBase\"].", null))); }
Example #15
Source File: KafkaAppenderTest.java From logback-kafka-appender with Apache License 2.0 | 5 votes |
@Test public void testDontStartWithoutEncoder() { unit.setEncoder(null); unit.start(); assertFalse("isStarted", unit.isStarted()); assertThat(ctx.getStatusManager().getCopyOfStatusList(), hasItem(new ErrorStatus("No encoder set for the appender named [\"kafkaAppenderBase\"].", null))); }
Example #16
Source File: ContextInitializer.java From stategen with GNU Affero General Public License v3.0 | 4 votes |
private URL loadURLFormPropertiesFile(ClassLoader myClassLoader, boolean updateStatus) throws IOException { StatusManager sm = loggerContext.getStatusManager(); sm.add(new InfoStatus("正在读取:" + application_properties, loggerContext)); URL application_url=getResource(application_properties, myClassLoader, updateStatus); if (application_url==null) { return null; } String applicationPropertiesPath = application_url.getPath(); Properties prop = new Properties(); @Cleanup InputStream in = null; try { sm.add(new InfoStatus(applicationPropertiesPath, loggerContext) ); in=myClassLoader.getResourceAsStream(application_properties); prop.load(in); if (!prop.containsKey(logback_config_xml_key)) { sm.add(new ErrorStatus(applicationPropertiesPath+" 文件中没有键:"+logback_config_xml_key, loggerContext) ); return null; } sm.add(new InfoStatus(applicationPropertiesPath+" 文件中有键:"+logback_config_xml_key, loggerContext) ); String logbackFile = prop.getProperty(logback_config_xml_key); logbackFile = logbackFile.trim(); if (logbackFile==null || logbackFile.isEmpty()) { sm.add(new ErrorStatus(applicationPropertiesPath+" 文件中键:"+logback_config_xml_key+" 为空!", loggerContext) ); return null; } sm.add(new InfoStatus(applicationPropertiesPath+" 文件中键:"+logback_config_xml_key+" 值为:"+logbackFile, loggerContext) ); logbackFile = OSUtil.getRealUriPathByOs(logbackFile); sm.add(new InfoStatus("Found logback configration :"+logbackFile, loggerContext) ); sm.add(new InfoStatus("加载真正的Logback配置文件:"+logbackFile, loggerContext)); URL url = new URL(logbackFile); return url; } catch (IOException e) { sm.add(new ErrorStatus( "Failed to get url list for resource [" + applicationPropertiesPath + "]", loggerContext, e)); } return null; }