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


Java MarkerFactory类代码示例

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


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

示例1: main

import org.slf4j.MarkerFactory; //导入依赖的package包/类
public static void main(String[] arg) {

        try {
            LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
            config.resizable = false;
            DesktopConfigEditor editor = new DesktopConfigEditor();
            Config cfg = DesktopConfigUtil.buildConfig(editor);
            DesktopConfigUtil.setupLwjglConfig(config, cfg);
            LwjglApplication application = new LwjglApplication(new ArcadeLegendsGame(cfg), config);
            //application.postRunnable(() -> application.getGraphics().setUndecorated(true));
            DesktopConfigUtil.registerStandardListeners(editor, cfg, config, application);


        } catch (Exception ex) {
            log.error(MarkerFactory.getMarker("ERROR"), "Error loading config", ex);
            System.exit(0);
        }

    }
 
开发者ID:EtherWorks,项目名称:arcadelegends-gg,代码行数:20,代码来源:DesktopLauncher.java

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: testConvert

import org.slf4j.MarkerFactory; //导入依赖的package包/类
@Test
public void testConvert() {

  final IndentConverter converter = new IndentConverter();

  assertEquals("Unexpected convertion", " ", converter.convert(new MockILoggingEvent()));
  assertEquals("Unexpected convertion", " ", converter.convert(new MockILoggingEvent(null, MarkerFactory.getMarker("unknown"), "message")));
  assertEquals("Unexpected convertion", "{", converter.convert(new MockILoggingEvent(null, LogMarker.ENTRY.getValue(), "message")));
  assertEquals("Unexpected convertion", "}", converter.convert(new MockILoggingEvent(null, LogMarker.EXIT.getValue(), "message")));
  assertEquals("Unexpected convertion", "d", converter.convert(new MockILoggingEvent(null, LogMarker.DATA.getValue(), "message")));
  assertEquals("Unexpected convertion", "!", converter.convert(new MockILoggingEvent(null, LogMarker.THROWING.getValue(), "message")));
  assertEquals("Unexpected convertion", "i", converter.convert(new MockILoggingEvent(null, LogMarker.INFO.getValue(), "message")));
  assertEquals("Unexpected convertion", "w", converter.convert(new MockILoggingEvent(null, LogMarker.WARNING.getValue(), "message")));
  assertEquals("Unexpected convertion", "e", converter.convert(new MockILoggingEvent(null, LogMarker.ERROR.getValue(), "message")));
  assertEquals("Unexpected convertion", "f", converter.convert(new MockILoggingEvent(null, LogMarker.FFDC.getValue(), "message")));
}
 
开发者ID:mqlight,项目名称:java-mqlight,代码行数:17,代码来源:TestIndentConverter.java

示例10: testDecide

import org.slf4j.MarkerFactory; //导入依赖的package包/类
@Test
public void testDecide() {

  final LogFilter filter = new LogFilter();

  assertEquals("Unexpected filter response", FilterReply.ACCEPT, filter.decide(new MockILoggingEvent()));
  assertEquals("Unexpected filter response", FilterReply.DENY, filter.decide(new MockILoggingEvent(null, LogMarker.ENTRY.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.DENY, filter.decide(new MockILoggingEvent(null, LogMarker.EXIT.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.DENY, filter.decide(new MockILoggingEvent(null, LogMarker.DATA.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.DENY, filter.decide(new MockILoggingEvent(null, LogMarker.THROWING.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.ACCEPT, filter.decide(new MockILoggingEvent(null, LogMarker.INFO.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.ACCEPT, filter.decide(new MockILoggingEvent(null, LogMarker.WARNING.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.ACCEPT, filter.decide(new MockILoggingEvent(null, LogMarker.ERROR.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.ACCEPT, filter.decide(new MockILoggingEvent(null, LogMarker.FFDC.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.ACCEPT, filter.decide(new MockILoggingEvent(null, MarkerFactory.getMarker("unknown"), "message", new Object[] { null })));
}
 
开发者ID:mqlight,项目名称:java-mqlight,代码行数:17,代码来源:TestLogFilter.java

示例11: testDecide

import org.slf4j.MarkerFactory; //导入依赖的package包/类
@Test
public void testDecide() {

  final TraceFilter filter = new TraceFilter();

  assertEquals("Unexpected filter response", FilterReply.DENY, filter.decide(new MockILoggingEvent()));
  assertEquals("Unexpected filter response", FilterReply.ACCEPT, filter.decide(new MockILoggingEvent(null, LogMarker.ENTRY.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.ACCEPT, filter.decide(new MockILoggingEvent(null, LogMarker.EXIT.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.ACCEPT, filter.decide(new MockILoggingEvent(null, LogMarker.DATA.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.ACCEPT, filter.decide(new MockILoggingEvent(null, LogMarker.THROWING.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.DENY, filter.decide(new MockILoggingEvent(null, LogMarker.INFO.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.DENY, filter.decide(new MockILoggingEvent(null, LogMarker.WARNING.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.DENY, filter.decide(new MockILoggingEvent(null, LogMarker.ERROR.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.DENY, filter.decide(new MockILoggingEvent(null, LogMarker.FFDC.getValue(), "message", new Object[] { null })));
  assertEquals("Unexpected filter response", FilterReply.DENY, filter.decide(new MockILoggingEvent(null, MarkerFactory.getMarker("unknown"), "message", new Object[] { null })));
}
 
开发者ID:mqlight,项目名称:java-mqlight,代码行数:17,代码来源:TestTraceFilter.java

示例12: test

import org.slf4j.MarkerFactory; //导入依赖的package包/类
@Test
public void test() {
	Map<String, String> contextMap = new HashMap<String, String>();
	contextMap.put("authenticationToken", null);
	contextMap.put("ipAddress", "192.168.254.254");
	contextMap.put("method", "GET");
	contextMap.put("request", "/users");
	MDC.setContextMap(contextMap);

	Marker securityAlertMarker = MarkerFactory.getDetachedMarker("SECURITY_ALERT");

	logger.error(securityAlertMarker, "Usuer not currently logged in");

	assertThat(logger, hasAtLeastOneEntry(that(allOf(
			haveLevel(LoggingLevel.ERROR),
			containMDC("authenticationToken", nullValue()),
			containMDC("request", anything()),
			containMarker("SECURITY_ALERT"),
			haveMessage(allOf(
					containsString("not"),
					containsString("logged")
					)))
			)));
}
 
开发者ID:answer-it,项目名称:mock-slf4j,代码行数:25,代码来源:ComplexMatchersTest.java

示例13: getMapping

import org.slf4j.MarkerFactory; //导入依赖的package包/类
/**
 * Computes a mapping between a source and a target.
 *
 * @param source
 *            Source cache
 * @param target
 *            Target cache
 * @param sourceVar
 *            Variable for the source dataset
 * @param targetVar
 *            Variable for the target dataset
 * @param expression
 *            Expression to process.
 * @param threshold
 *            Similarity threshold
 * @return A mapping which contains links between the source instances and
 *         the target instances
 */
@Override
public AMapping getMapping(ACache source, ACache target, String sourceVar, String targetVar, String expression,
        double threshold) {
    if (threshold <= 0) {
        throw new InvalidThresholdException(threshold);
    }
    List<String> properties = PropertyFetcher.getProperties(expression, threshold);
    // if no properties then terminate
    if (properties.get(0) == null || properties.get(1) == null) {
        logger.error(MarkerFactory.getMarker("FATAL"), "Property values could not be read. Exiting");
        throw new RuntimeException();
    }
    Map<String, Set<String>> sourceIndex = getValueToUriMap(source, properties.get(0));
    Map<String, Set<String>> targetIndex = getValueToUriMap(target, properties.get(1));
    AMapping m = MappingFactory.createDefaultMapping();
    boolean swapped = sourceIndex.keySet().size() > targetIndex.keySet().size();
    (swapped ? sourceIndex : targetIndex).keySet().stream().filter(targetIndex::containsKey).forEach(value -> {
        for (String sourceUri : (swapped ? sourceIndex : targetIndex).get(value)) {
            for (String targetUri : (swapped ? targetIndex : sourceIndex).get(value)) {
                m.add(sourceUri, targetUri, 1d);
            }
        }
    });
    return m;
}
 
开发者ID:dice-group,项目名称:LIMES,代码行数:44,代码来源:ExactMatchMapper.java

示例14: run

import org.slf4j.MarkerFactory; //导入依赖的package包/类
@Override
public void run()
{
    try
    {
        int totalLoops = 10;
        Thread.sleep( 0 );
        int i = 0;
        do
        {
            tune( service, path, stbModel, "25" );
            Thread.sleep( 3000 );
            tune( service, path, stbModel, "37" );
            i++;
        } while ( i < totalLoops );
    }
    catch ( InterruptedException ex )
    {
        LoggerFactory.getLogger(SimpleIRThread.class.getName()).error(MarkerFactory.getMarker("SEVERE"), null, ex);
    }
}
 
开发者ID:Comcast,项目名称:cats,代码行数:22,代码来源:SimpleIRThread.java

示例15: 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


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