當前位置: 首頁>>代碼示例>>Java>>正文


Java MarkerFactory.getMarker方法代碼示例

本文整理匯總了Java中org.slf4j.MarkerFactory.getMarker方法的典型用法代碼示例。如果您正苦於以下問題:Java MarkerFactory.getMarker方法的具體用法?Java MarkerFactory.getMarker怎麽用?Java MarkerFactory.getMarker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.slf4j.MarkerFactory的用法示例。


在下文中一共展示了MarkerFactory.getMarker方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testMarker

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
@Test
public void testMarker() throws Exception {
    String token = "markerToken";
    String type = "markerType";
    String loggerName = "markerTesting";
    String markerKey = "marker";
    String markerTestValue = "MyMarker";
    int drainTimeout = 1;
    String message1 = "Simple log line - "+random(5);

    Marker marker = MarkerFactory.getMarker(markerTestValue);

    Logger testLogger = createLogger(token, type, loggerName, drainTimeout, false, false, null);
    testLogger.info(marker, message1);

    sleepSeconds(2 * drainTimeout);

    mockListener.assertNumberOfReceivedMsgs(1);
    MockLogzioBulkListener.LogRequest logRequest = mockListener.assertLogReceivedByMessage(message1);
    mockListener.assertLogReceivedIs(logRequest, token, type, loggerName, Level.INFO.levelStr);
    assertThat(logRequest.getStringFieldOrNull(markerKey)).isEqualTo(markerTestValue);
}
 
開發者ID:logzio,項目名稱:logzio-logback-appender,代碼行數:23,代碼來源:LogzioLogbackAppenderTest.java

示例2: testCategorties

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
@Test
public void testCategorties() {
    logMsg = "Running testCategories()";
    Marker cat0 = MarkerFactory.getMarker("cat0");

    LOGGER.info(cat0, logMsg);
    assertThat(getMessage(), is(logMsg));
    assertThat(getField(Fields.COMPONENT_ID), is("-"));
    assertThat(getField(Fields.COMPONENT_NAME), is("-"));
    assertThat(getField(Fields.COMPONENT_INSTANCE), is("0"));
    assertThat(getField(Fields.WRITTEN_TS), is(notNullValue()));
    assertThat(getList(Fields.CATEGORIES), contains(cat0.getName()));

    Marker cat1 = MarkerFactory.getMarker("cat1");
    cat1.add(cat0);

    LOGGER.info(cat1, logMsg);
    assertThat(getMessage(), is(logMsg));
    assertThat(getField(Fields.COMPONENT_ID), is("-"));
    assertThat(getField(Fields.COMPONENT_NAME), is("-"));
    assertThat(getField(Fields.COMPONENT_INSTANCE), is("0"));
    assertThat(getField(Fields.WRITTEN_TS), is(notNullValue()));
    assertThat(getList(Fields.CATEGORIES), contains(cat1.getName(), cat0.getName()));
}
 
開發者ID:SAP,項目名稱:cf-java-logging-support,代碼行數:25,代碼來源:TestAppLog.java

示例3: init

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet());
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .markWith(metricsMarker)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
開發者ID:kalnee,項目名稱:trivor,代碼行數:27,代碼來源:MetricsConfiguration.java

示例4: mapSupportLevel

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
protected void mapSupportLevel(String message, Throwable t) {
    Marker supportMarker = MarkerFactory.getMarker(SUPPORT);

    switch (getSupportLevel()) {
        case LOG_LEVEL_ERROR:
            LOGGER.error(supportMarker, message, t);
            break;
        case LOG_LEVEL_INFO:
            LOGGER.info(supportMarker, message, t);
            break;
        case LOG_LEVEL_DEBUG:
            LOGGER.debug(supportMarker, message, t);
            break;
        case LOG_LEVEL_TRACE:
            LOGGER.trace(supportMarker, message, t);
            break;
        default:
            LOGGER.warn(supportMarker, message, t);
    }

}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:22,代碼來源:SLF4JSupportLoggerAdapter.java

示例5: testComposite

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
@Test
public void testComposite() {
  String compositeMarkerName = COMPOSITE;
  Marker compositeMarker = MarkerFactory.getMarker(compositeMarkerName);
  compositeMarker.add(totoMarker);

  MarkerFilter mkt = new MarkerFilter();
  mkt.setMarker(TOTO);
  mkt.setOnMatch("ACCEPT");
  mkt.setOnMismatch("DENY");

  mkt.start();

  assertTrue(mkt.isStarted());
  assertEquals(FilterReply.DENY, mkt.decide(null, null, null, null, null, null));
  assertEquals(FilterReply.ACCEPT, mkt.decide(totoMarker, null, null, null, null, null));
  assertEquals(FilterReply.ACCEPT, mkt.decide(compositeMarker, null, null, null, null, null));
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:19,代碼來源:MarkerFilterTest.java

示例6: testIgnoreMarker

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
@Test
public void testIgnoreMarker() throws NullPointerException, EvaluationException, JoranException {
  JoranConfigurator jc = new JoranConfigurator();
  LoggerContext loggerContext = new LoggerContext();
  jc.setContext(loggerContext);
  jc.doConfigure(ClassicTestConstants.JORAN_INPUT_PREFIX + "ignore.xml");
  
  Map evalMap = (Map) loggerContext.getObject(CoreConstants.EVALUATOR_MAP);
  assertNotNull(evalMap);
  
  Logger logger = loggerContext.getLogger("xx");
  
  JaninoEventEvaluator evaluator = (JaninoEventEvaluator) evalMap.get("IGNORE_EVAL");
  LoggingEvent event = new LoggingEvent("foo", logger, Level.DEBUG, "Hello world",null, null);

  Marker ignoreMarker = MarkerFactory.getMarker("IGNORE");
  event.setMarker(ignoreMarker);
  assertTrue(evaluator.evaluate(event));
  
  logger.debug("hello", new Exception("test"));
  logger.debug(ignoreMarker, "hello ignore", new Exception("test"));
  
  //logger.debug("hello", new Exception("test"));
  
  //StatusPrinter.print(loggerContext.getStatusManager());
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:27,代碼來源:EvaluatorJoranTest.java

示例7: log

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
/**
 * Logs a message.
 */
@Override
public void log(final int priority, final String tag, final String message) {
	final Marker marker = MarkerFactory.getMarker(tag);
	switch (priority) {

	case AxolotlLogger.VERBOSE:
	case AxolotlLogger.DEBUG:
		LOGGER.debug(marker, message);
		break;
	case AxolotlLogger.INFO:
		LOGGER.info(marker, message);
		break;
	case AxolotlLogger.WARN:
		LOGGER.warn(marker, message);
		break;
	case AxolotlLogger.ERROR:
		LOGGER.error(marker, message);
		break;
	case AxolotlLogger.ASSERT:
		LOGGER.trace(marker, message);
		break;
	default:
		LOGGER.error(marker, "## Unknown Loglevel Message: ##" + message);
	}
}
 
開發者ID:connorlanigan,項目名稱:norvos,代碼行數:29,代碼來源:AxolotlLoggerImpl.java

示例8: logException

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
/**
 * Logs the exception; on ERROR level when status is 5xx, otherwise on INFO level without stack
 * trace, or DEBUG level with stack trace. The logger name is
 * {@code cz.jirutka.spring.exhandler.handlers.RestExceptionHandler}.
 *
 * @param ex The exception to log.
 * @param req The current web request.
 */
protected void logException(E ex, HttpServletRequest req) {

    if (LOG.isErrorEnabled() && getStatus().value() >= 500 || LOG.isInfoEnabled()) {
        Marker marker = MarkerFactory.getMarker(ex.getClass().getName());

        String uri = req.getRequestURI();
        if (req.getQueryString() != null) {
            uri += '?' + req.getQueryString();
        }
        String msg = String.format("%s %s ~> %s", req.getMethod(), uri, getStatus());

        if (getStatus().value() >= 500) {
            LOG.error(marker, msg, ex);

        } else if (LOG.isDebugEnabled()) {
            LOG.debug(marker, msg, ex);

        } else {
            LOG.info(marker, msg);
        }
    }
}
 
開發者ID:jirutka,項目名稱:spring-rest-exception-handler,代碼行數:31,代碼來源:AbstractRestExceptionHandler.java

示例9: resourceOffers

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
@Override
public void resourceOffers(final SchedulerDriver driver, final List<Offer> offers) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("> resourceOffers(driver : {}, offers : {})", driver, protoToString(offers));
    }

    for (final Offer offer : offers) {
        final Marker marker = MarkerFactory.getMarker("offerId:" + offer.getId().getValue() + ",hostname:" + offer.getHostname());
        final boolean offerUsed = evaluateOffer(driver, marker, offer);
        if (!offerUsed) {
            LOGGER.trace(marker, "Declining Offer: {}", offer.getId().getValue());
            driver.declineOffer(offer.getId());
        }
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("< resourceOffers(driver : {}, offers : {})", driver, protoToString(offers));
    }
}
 
開發者ID:mesosphere,項目名稱:cassandra-mesos-deprecated,代碼行數:19,代碼來源:CassandraScheduler.java

示例10: allResourcesAvailableBeforeLaunchingExecutor

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
@Test
public void allResourcesAvailableBeforeLaunchingExecutor() throws Exception {
    cleanState();

    final String role = "*";
    final Protos.Offer offer = Protos.Offer.newBuilder()
        .setFrameworkId(frameworkId)
        .setHostname("localhost")
        .setId(Protos.OfferID.newBuilder().setValue(randomID()))
        .setSlaveId(Protos.SlaveID.newBuilder().setValue("slave_1"))
        .addResources(cpu(0.1, role))
        .addResources(mem(0.1, role))
        .addResources(disk(0.1, role))
        .addResources(ports(Lists.<Long>emptyList(), role))
        .build();
    final Marker marker = MarkerFactory.getMarker("offerId:" + offer.getId().getValue() + ",hostname:" + offer.getHostname());
    assertThat(cluster._getTasksForOffer(marker, offer)).isNull();
}
 
開發者ID:mesosphere,項目名稱:cassandra-mesos-deprecated,代碼行數:19,代碼來源:CassandraClusterStateTest.java

示例11: getMarker

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
private org.slf4j.Marker getMarker(final Marker marker) {
    if (marker == null) {
        return null;
    }
    final org.slf4j.Marker slf4jMarker = MarkerFactory.getMarker(marker.getName());
    final Marker[] parents = marker.getParents();
    if (parents != null) {
        for (final Marker parent : parents) {
            final org.slf4j.Marker slf4jParent = getMarker(parent);
            if (!slf4jMarker.contains(slf4jParent)) {
                slf4jMarker.add(slf4jParent);
            }
        }
    }
    return slf4jMarker;
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:17,代碼來源:SLF4JLogger.java

示例12: init

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet());
    if (hikariDataSource != null) {
        log.debug("Monitoring the datasource");
        hikariDataSource.setMetricRegistry(metricRegistry);
    }
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .markWith(metricsMarker)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
開發者ID:xm-online,項目名稱:xm-ms-balance,代碼行數:31,代碼來源:MetricsConfiguration.java

示例13: init

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet());
    if (hikariDataSource != null) {
        log.debug("Monitoring the datasource");
        hikariDataSource.setMetricRegistry(metricRegistry);
    }
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .markWith(metricsMarker)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
開發者ID:torgcrm,項目名稱:TorgCRM-Server,代碼行數:32,代碼來源:MetricsConfiguration.java

示例14: write

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
public static void write(Class clazz, LogLevel logLevel, String message) {
    Logger logger = LoggerFactory.getLogger(clazz);

    switch (logLevel) {
    case TRACE:
        logger.trace(message);
        break;
    case DEBUG:
        logger.debug(message);
        break;
    case INFO:
        logger.info(message);
        break;
    case WARN:
        logger.warn(message);
        break;
    case ERROR:
        logger.error(message);
        break;
    case FATAL:
        Marker marker = MarkerFactory.getMarker("FATAL");
        logger.error(marker, message);
        break;
    default:
        logger.warn("No suitable log level found");
        break;
    }
}
 
開發者ID:voyages-sncf-technologies,項目名稱:cerebro,代碼行數:29,代碼來源:LogWriter.java

示例15: log

import org.slf4j.MarkerFactory; //導入方法依賴的package包/類
@Override
public void log(Class<?> clazz, String method, Level level, String message, Throwable ex) {
	Trace LOGGER = TraceManager.getTrace(clazz);
	//Mark all messages from ICF as ICF
	Marker m = MarkerFactory.getMarker("ICF");
	
	//Translate ICF logging into slf4j
	// OK    -> trace
	// INFO  -> debug
	// WARN  -> warn
	// ERROR -> error
	if (Level.OK.equals(level)) {
		if (null == ex) {
			LOGGER.trace(m, "method: {} msg:{}", method, message);
		} else {
			LOGGER.trace(m, "method: {} msg:{}", new Object[] { method, message }, ex);
		}
	} else if (Level.INFO.equals(level)) {
		if (null == ex) {
			LOGGER.debug(m, "method: {} msg:{}", method, message);
		} else {
			LOGGER.debug(m, "method: {} msg:{}", new Object[] { method, message }, ex);
		}
	} else if (Level.WARN.equals(level)) {
		if (null == ex) {
			LOGGER.warn(m, "method: {} msg:{}", method, message);
		} else {
			LOGGER.warn(m, "method: {} msg:{}", new Object[] { method, message }, ex);
		}
	} else if (Level.ERROR.equals(level)) {
		if (null == ex) {
			LOGGER.error(m, "method: {} msg:{}", method, message);
		} else {
			LOGGER.error(m, "method: {} msg:{}", new Object[] { method, message }, ex);
		}
	}
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:38,代碼來源:Slf4jConnectorLogger.java


注:本文中的org.slf4j.MarkerFactory.getMarker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。