org.slf4j.MarkerFactory Java Examples
The following examples show how to use
org.slf4j.MarkerFactory.
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: MetricsConfiguration.java From cubeai with Apache License 2.0 | 7 votes |
@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); } }
Example #2
Source File: SLF4JLogger.java From logging-log4j2 with Apache License 2.0 | 6 votes |
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; }
Example #3
Source File: MetricsConfiguration.java From okta-jhipster-microservices-oauth-example with Apache License 2.0 | 6 votes |
@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); } }
Example #4
Source File: ShutdownHooks.java From hivemq-community-edition with Apache License 2.0 | 6 votes |
private void createShutdownThread() { hivemqShutdownThread = new Thread(() -> { SHUTTING_DOWN.set(true); log.info("Shutting down HiveMQ. Please wait, this could take a while..."); log.trace("Running synchronous shutdown hook"); final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); executorService.scheduleAtFixedRate( () -> log.info( "Still shutting down HiveMQ. Waiting for remaining tasks to be executed. Do not shutdown HiveMQ."), 10, 10, TimeUnit.SECONDS); for (final HiveMQShutdownHook runnable : registry.values()) { log.trace(MarkerFactory.getMarker("SHUTDOWN_HOOK"), "Running shutdown hook {}", runnable.name()); //Although these shutdown hooks are threads, we're calling only the blocking run method runnable.run(); } executorService.shutdown(); }, SHUTDOWN_HOOK_THREAD_NAME); }
Example #5
Source File: MetricsConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
@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); } }
Example #6
Source File: MetricsConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
@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); } }
Example #7
Source File: MetricsConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
@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); } }
Example #8
Source File: MetricsConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
@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); } }
Example #9
Source File: MetricsConfiguration.java From cubeai with Apache License 2.0 | 6 votes |
@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); } }
Example #10
Source File: MetricsConfiguration.java From flair-registry with Apache License 2.0 | 6 votes |
@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())); 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); } }
Example #11
Source File: MetricsConfiguration.java From e-commerce-microservice with Apache License 2.0 | 6 votes |
@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); } }
Example #12
Source File: LogLevelInfoFilterTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test public void filtersLevelTestWithMarker() { Marker marker = MarkerFactory.getMarker(APIML_MARKER); Map<Level, Boolean> filteringMap = new HashMap<>(); filteringMap.put(Level.TRACE, false); filteringMap.put(Level.DEBUG, false); filteringMap.put(Level.INFO, false); filteringMap.put(Level.WARN, false); filteringMap.put(Level.ERROR, false); filteringMap.forEach((level, shouldFilter) -> { FilterReply reply = filterInstance.decide(marker, (ch.qos.logback.classic.Logger) log, level, "", null, null); assertEquals("Logging level with apiml marker " + level.toString() + " not filtered correctly", shouldFilter ? FilterReply.DENY : FilterReply.NEUTRAL, reply); }); }
Example #13
Source File: LogzioLogbackAppenderTest.java From logzio-logback-appender with Apache License 2.0 | 6 votes |
@Test public void testMarker() throws Exception { String token = "markerToken"; String type = "markerType" + random(8); String loggerName = "markerTesting" + random(8); String markerKey = "marker"; String markerTestValue = "MyMarker"; int drainTimeout = 1; String message1 = "Simple log line - "+random(5); Marker marker = MarkerFactory.getMarker(markerTestValue); Logger testLogger = createLogger(logzioLogbackAppender, token, type, loggerName, drainTimeout, false, false, null, false); 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); }
Example #14
Source File: TestAppLog.java From cf-java-logging-support with Apache License 2.0 | 6 votes |
@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())); }
Example #15
Source File: GoConfigMigrator.java From gocd with Apache License 2.0 | 6 votes |
@Autowired public GoConfigMigrator(GoConfigMigration goConfigMigration, SystemEnvironment systemEnvironment, ConfigCache configCache, ConfigElementImplementationRegistry registry, FullConfigSaveNormalFlow fullConfigSaveNormalFlow, ConfigRepository configRepository, ServerHealthService serverHealthService) { this(goConfigMigration, systemEnvironment, fullConfigSaveNormalFlow, new MagicalGoConfigXmlLoader(configCache, registry), new GoConfigFileReader(systemEnvironment), configRepository, serverHealthService, e -> { e.printStackTrace(); System.err.println( "There are errors in the Cruise config file. Please read the error message and correct the errors.\n" + "Once fixed, please restart GoCD.\nError: " + e.getMessage()); LOGGER.error(MarkerFactory.getMarker("FATAL"), "There are errors in the Cruise config file. Please read the error message and correct the errors.\n" + "Once fixed, please restart GoCD.\nError: " + e.getMessage()); // Send exit signal in a separate thread otherwise it will deadlock jetty new Thread(() -> System.exit(1)).start(); }); }
Example #16
Source File: CassandraClusterStateTest.java From cassandra-mesos-deprecated with Apache License 2.0 | 6 votes |
@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(); }
Example #17
Source File: CassandraScheduler.java From cassandra-mesos-deprecated with Apache License 2.0 | 6 votes |
@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)); } }
Example #18
Source File: AbstractRestExceptionHandler.java From spring-rest-exception-handler with Apache License 2.0 | 6 votes |
/** * 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); } } }
Example #19
Source File: TestAppLog.java From cf-java-logging-support with Apache License 2.0 | 6 votes |
@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())); }
Example #20
Source File: HttpSolrCall.java From lucene-solr with Apache License 2.0 | 6 votes |
private void handleAdminRequest() throws IOException { SolrQueryResponse solrResp = new SolrQueryResponse(); SolrCore.preDecorateResponse(solrReq, solrResp); handleAdmin(solrResp); SolrCore.postDecorateResponse(handler, solrReq, solrResp); if (solrResp.getToLog().size() > 0) { if (log.isInfoEnabled()) { // has to come second and in it's own if to keep ./gradlew check happy. log.info(handler != null ? MarkerFactory.getMarker(handler.getClass().getName()) : MarkerFactory.getMarker(HttpSolrCall.class.getName()), solrResp.getToLogAsString("[admin]")); } } QueryResponseWriter respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get(solrReq.getParams().get(CommonParams.WT)); if (respWriter == null) respWriter = getResponseWriter(); writeResponse(solrResp, respWriter, Method.getMethod(req.getMethod())); if (shouldAudit()) { EventType eventType = solrResp.getException() == null ? EventType.COMPLETED : EventType.ERROR; if (shouldAudit(eventType)) { cores.getAuditLoggerPlugin().doAudit( new AuditEvent(eventType, req, getAuthCtx(), solrReq.getRequestTimer().getTime(), solrResp.getException())); } } }
Example #21
Source File: GelfEncoderTest.java From logback-gelf with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void multipleMarker() throws IOException { encoder.setLoggerNameKey("Logger"); encoder.start(); final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); final Logger logger = lc.getLogger(LOGGER_NAME); final LoggingEvent event = simpleLoggingEvent(logger, null); final Marker marker = MarkerFactory.getMarker("FIRST"); marker.add(MarkerFactory.getMarker("SECOND")); event.setMarker(marker); final String logMsg = encodeToStr(event); final ObjectMapper om = new ObjectMapper(); final JsonNode jsonNode = om.readTree(logMsg); coreValidation(jsonNode); assertEquals("FIRST, SECOND", jsonNode.get("_marker").textValue()); }
Example #22
Source File: GelfEncoderTest.java From logback-gelf with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void singleMarker() throws IOException { encoder.setLoggerNameKey("Logger"); encoder.start(); final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); final Logger logger = lc.getLogger(LOGGER_NAME); final LoggingEvent event = simpleLoggingEvent(logger, null); event.setMarker(MarkerFactory.getMarker("SINGLE")); final String logMsg = encodeToStr(event); final ObjectMapper om = new ObjectMapper(); final JsonNode jsonNode = om.readTree(logMsg); coreValidation(jsonNode); assertEquals("SINGLE", jsonNode.get("_marker").textValue()); }
Example #23
Source File: KBCore.java From Stargraph with MIT License | 6 votes |
public KBCore(String kbName, Stargraph stargraph, boolean start) { this.kbName = Objects.requireNonNull(kbName); this.stargraph = Objects.requireNonNull(stargraph); this.mainConfig = stargraph.getMainConfig(); this.kbConfig = mainConfig.getConfig(String.format("kb.%s", kbName)); this.marker = MarkerFactory.getMarker(kbName); this.indexers = new ConcurrentHashMap<>(); this.searchers = new ConcurrentHashMap<>(); this.searchQueryGenerators = new ConcurrentHashMap<>(); this.language = Language.valueOf(kbConfig.getString("language").toUpperCase()); if (kbConfig.hasPathOrNull("ner-kb")) { if (kbConfig.getIsNull("ner-kb")) { throw new StarGraphException("No NER-KB configured."); } this.nerKbName = kbConfig.getString("ner-kb"); } else { this.nerKbName = kbName; } this.namespace = Namespace.create(kbConfig); if (start) { initialize(); } }
Example #24
Source File: MarkerFilterBenchmark.java From logging-log4j2 with Apache License 2.0 | 5 votes |
@Setup public void setUp() { System.setProperty("log4j.configurationFile", "log4j2-markerFilter-perf.xml"); System.setProperty("logback.configurationFile", "logback-markerFilter-perf.xml"); LOGBACK_FLOW_MARKER = MarkerFactory.getMarker("FLOW"); LOGBACK_ENTRY_MARKER = MarkerFactory.getMarker("ENTRY"); LOG4J_FLOW_MARKER = MarkerManager.getMarker("FLOW"); LOG4J_ENTRY_MARKER = MarkerManager.getMarker("ENTRY"); LOGBACK_ENTRY_MARKER.add(LOGBACK_FLOW_MARKER); LOG4J_ENTRY_MARKER.addParents(LOG4J_FLOW_MARKER); log4jLogger = LogManager.getLogger(MarkerFilterBenchmark.class); slf4jLogger = LoggerFactory.getLogger(MarkerFilterBenchmark.class); }
Example #25
Source File: JHipsterLoggingMetricsExportConfiguration.java From jhipster with Apache License 2.0 | 5 votes |
/** * <p>consoleReporter.</p> * * @param dropwizardRegistry a {@link com.codahale.metrics.MetricRegistry} object. * @return a {@link com.codahale.metrics.Slf4jReporter} object. */ @Bean public Slf4jReporter consoleReporter(MetricRegistry dropwizardRegistry) { log.info("Initializing Metrics Log reporting"); Marker metricsMarker = MarkerFactory.getMarker("metrics"); final Slf4jReporter reporter = Slf4jReporter.forRegistry(dropwizardRegistry) .outputTo(LoggerFactory.getLogger("metrics")) .markWith(metricsMarker) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS); return reporter; }
Example #26
Source File: MarkerConverter.java From graylog-plugin-metrics-reporter with GNU General Public License v3.0 | 5 votes |
@Override public Marker convertFrom(String value) { if (value == null) { throw new ParameterException("Couldn't convert value \"null\" to marker."); } return MarkerFactory.getMarker(value); }
Example #27
Source File: GelfAppenderTest.java From logback-gelf-appender with Apache License 2.0 | 5 votes |
@Test void testMarker() { Logger logger = LoggerFactory.getLogger("test"); final Marker marker = MarkerFactory.getMarker("TEST"); logger.info(marker, "hello"); }
Example #28
Source File: SimpleController.java From tutorials with MIT License | 5 votes |
@GetMapping("/slf4j-guide-marker-request") public String clientMarkerRequest() throws InterruptedException { logger.info("client has made a request"); Marker myMarker = MarkerFactory.getMarker("MYMARKER"); logger.info(myMarker, "Starting request"); Thread.sleep(500); logger.debug(myMarker, "Finished request"); return "finished"; }
Example #29
Source File: MetricsConfiguration.java From e-commerce-microservice with Apache License 2.0 | 5 votes |
@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"); // remove the factory created by HikariDataSourceMetricsPostProcessor until JHipster migrate to Micrometer hikariDataSource.setMetricsTrackerFactory(null); 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); } }
Example #30
Source File: MetricsConfiguration.java From ehcache3-samples with Apache License 2.0 | 5 votes |
@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"); // remove the factory created by HikariDataSourceMetricsPostProcessor until JHipster migrate to Micrometer hikariDataSource.setMetricsTrackerFactory(null); 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); } }