org.slf4j.Marker Java Examples
The following examples show how to use
org.slf4j.Marker.
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 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 #2
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 #3
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 #4
Source File: CategoriesConverter.java From cf-java-logging-support with Apache License 2.0 | 5 votes |
private void getMarkersRecursively(Marker marker, ArrayComposer<JSONComposer<String>> ac) throws IOException { if (marker != null) { ac.add(marker.getName()); Iterator<Marker> it = marker.iterator(); while (it.hasNext()) { getMarkersRecursively(it.next(), ac); } } }
Example #5
Source File: LambdaLoggerPlainImpl.java From slf4j-lambda with Apache License 2.0 | 5 votes |
@Override public void doLog(Marker marker, Level level, String format, Object[] arguments, Throwable t) { if (!LambdaLoggerUtils.isLogLevelEnabled(underlyingLogger, level, marker)) { return; } if (arguments == null) { logFormatted(marker, level, format, t); } else { FormattingTuple formattingTuple = MessageFormatter.arrayFormat(format, arguments, t); logFormatted(marker, level, formattingTuple.getMessage(), formattingTuple.getThrowable()); } }
Example #6
Source File: Slf4jReporter.java From metrics with Apache License 2.0 | 5 votes |
private Slf4jReporter(MetricRegistry registry, LoggerProxy loggerProxy, Marker marker, String prefix, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter) { super(registry, "logger-reporter", filter, rateUnit, durationUnit); this.loggerProxy = loggerProxy; this.marker = marker; this.prefix = MetricName.build(prefix); }
Example #7
Source File: WandoraLoggerAdapter.java From wandora with GNU General Public License v3.0 | 5 votes |
@Override public void error(Marker marker, String string, Object[] os) { if(isErrorEnabled(marker)) { log(string); log(os); } }
Example #8
Source File: LazyLoggerImpl.java From metron with Apache License 2.0 | 5 votes |
@Override @SafeVarargs public final void trace(Marker marker, String format, Supplier<Object>... arguments) { if (logger.isTraceEnabled(marker)) { logger.trace(marker, format, Arrays.stream(arguments).map(Supplier::get).toArray()); } }
Example #9
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 #10
Source File: DefaultAutoCloseableSlf4jLogger.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Override public void info(final Marker marker, final String format, final Object... arguments) { if (isInfoEnabled(marker)) { putCorrelationIdToMdc(); actualSlf4jLogger.info(marker, format, arguments); } }
Example #11
Source File: DefaultLogger.java From common-utils with GNU General Public License v2.0 | 5 votes |
@Override public void errorIfEnabled(Marker marker, String msg) { if (logger.isErrorEnabled()) { logger.error(marker, msg); } }
Example #12
Source File: Slf4jLoggerTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void testLocationAwareLogger() { LocationAwareLogger locationAwareLogger = mock(LocationAwareLogger.class); Slf4jLogger logger = new Slf4jLogger(locationAwareLogger); logger.error("error"); ; logger.warn("warn"); logger.info("info"); logger.debug("debug"); logger.trace("info"); verify(locationAwareLogger, times(5)).log(isNull(Marker.class), anyString(), anyInt(), anyString(), isNull(Object[].class), isNull(Throwable.class)); logger.error(new Exception("error")); logger.warn(new Exception("warn")); logger.info(new Exception("info")); logger.debug(new Exception("debug")); logger.trace(new Exception("trace")); logger.error("error", new Exception("error")); logger.warn("warn", new Exception("warn")); logger.info("info", new Exception("info")); logger.debug("debug", new Exception("debug")); logger.trace("trace", new Exception("trace")); verify(locationAwareLogger, times(10)).log(isNull(Marker.class), anyString(), anyInt(), anyString(), isNull(Object[].class), any(Throwable.class)); }
Example #13
Source File: IgnoreLoggerFilter.java From tutorials with MIT License | 5 votes |
@Override public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) { if (loggerName == null) { return FilterReply.NEUTRAL; } else if (loggerName.equals(logger.getName())) { return FilterReply.DENY; } else return FilterReply.NEUTRAL; }
Example #14
Source File: RateLogger.java From more-lambdas-java with Artistic License 2.0 | 5 votes |
@Override public void debug(Marker marker, String format, Object arg1, Object arg2) { if (isDebugEnabled(marker) && canDo()) { if (locationAwareLogger != null) { locationAwareLogger.log(marker, FQCN, DEBUG_INT, msg(format), args(new Object[]{arg1, arg2}), null); } else { logger.debug(marker, msg(format), args(new Object[]{arg1, arg2})); } } }
Example #15
Source File: DefaultLogger.java From common-utils with GNU General Public License v2.0 | 5 votes |
@Override public void infoIfEnabled(Marker marker, String msg, Throwable t) { if (logger.isInfoEnabled()) { logger.info(marker, msg, t); } }
Example #16
Source File: Log4jLogger.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public void trace(final Marker marker, final String s) { logger.logIfEnabled(FQCN, Level.TRACE, getMarker(marker), s); }
Example #17
Source File: AionLogger.java From aion with MIT License | 4 votes |
@Override public void error(Marker marker, String msg) { if (log.isErrorEnabled(marker)) { log.error(marker, msg); } }
Example #18
Source File: DefaultLogger.java From common-utils with GNU General Public License v2.0 | 4 votes |
@Override public boolean isTraceEnabled(Marker marker) { return logger.isTraceEnabled(marker); }
Example #19
Source File: Logger_common_impl.java From uima-uimaj with Apache License 2.0 | 4 votes |
@Override public void warn(Marker arg0, String arg1, Object arg2) { if (isLoggable(Level.WARNING, arg0) && isNotLimited(Level.WARNING)) { log2(arg0, fqcnCmn, Level.WARNING, arg1, new Object[] { arg2 }, null); } }
Example #20
Source File: LambdaLoggerLocationAwareImpl.java From slf4j-lambda with Apache License 2.0 | 4 votes |
@Override public void log(Marker marker, String fqcn, int level, String message, Object[] arguments, Throwable t) { underlyingLogger.log(marker, fqcn, level, message, arguments, t); }
Example #21
Source File: DelegatingLogger.java From atomix with Apache License 2.0 | 4 votes |
@Override public void trace(Marker marker, String msg, Throwable t) { delegate.trace(marker, msg, t); }
Example #22
Source File: RequestContextAwareLogger.java From armeria with Apache License 2.0 | 4 votes |
@Override public boolean isTraceEnabled(Marker marker) { return logger.isTraceEnabled(marker); }
Example #23
Source File: LevelledLoggerWrapper.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 4 votes |
public void error(Marker marker, String msg) { if (getLevel() <= LocationAwareLogger.ERROR_INT) { delegate.error(marker, msg); } }
Example #24
Source File: LogLogger.java From ymate-platform-v2 with Apache License 2.0 | 4 votes |
@Override public void error(final Marker marker, final String format, final Object arg1, final Object arg2) { if (isErrorEnabled(marker)) { __doBuildEx(__getSafeMessages(format, arg1, arg2), null, LogLevel.ERROR); } }
Example #25
Source File: OptimizelyLiteLogger.java From android-sdk with Apache License 2.0 | 4 votes |
@Override public void debug(Marker marker, String msg) { Log.d(tag, msg); }
Example #26
Source File: ProdObjectFactory.java From cassandra-mesos-deprecated with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private static void modifyCassandraYaml( @NotNull final Marker taskIdMarker, @NotNull final String version, @NotNull final CassandraServerConfig cassandraServerConfig ) throws IOException { LOGGER.info(taskIdMarker, "Building cassandra.yaml"); final File cassandraYaml = new File("apache-cassandra-" + version + "/conf/cassandra.yaml"); final Yaml yaml = new Yaml(); final Map<String, Object> yamlMap; LOGGER.info(taskIdMarker, "Reading cassandra.yaml"); try (BufferedReader br = new BufferedReader(new FileReader(cassandraYaml))) { yamlMap = (Map<String, Object>) yaml.load(br); } LOGGER.info(taskIdMarker, "Modifying cassandra.yaml"); for (final TaskConfig.Entry entry : cassandraServerConfig.getCassandraYamlConfig().getVariablesList()) { switch (entry.getName()) { case "seeds": final List<Map<String, Object>> seedProviderList = (List<Map<String, Object>>) yamlMap.get("seed_provider"); final Map<String, Object> seedProviderMap = seedProviderList.get(0); final List<Map<String, Object>> parameters = (List<Map<String, Object>>) seedProviderMap.get("parameters"); final Map<String, Object> parametersMap = parameters.get(0); parametersMap.put("seeds", entry.getStringValue()); break; default: if (entry.hasStringValue()) { yamlMap.put(entry.getName(), entry.getStringValue()); } else if (entry.hasLongValue()) { yamlMap.put(entry.getName(), entry.getLongValue()); } else if (!entry.getStringValuesList().isEmpty()) { yamlMap.put(entry.getName(), entry.getStringValuesList()); } } } if (LOGGER.isDebugEnabled()) { final StringWriter sw = new StringWriter(); yaml.dump(yamlMap, sw); LOGGER.debug("cassandra.yaml result: {}", sw); } LOGGER.info(taskIdMarker, "Writing cassandra.yaml"); try (BufferedWriter bw = new BufferedWriter(new FileWriter(cassandraYaml))) { yaml.dump(yamlMap, bw); } }
Example #27
Source File: TagLogger.java From pravega with Apache License 2.0 | 4 votes |
@Override public void debug(Marker marker, String msg, Throwable t) { log.debug(marker, msg, t); }
Example #28
Source File: Logging.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public boolean isTraceEnabled(Marker marker) { return logger.isTraceEnabled(marker); }
Example #29
Source File: ArkLogger.java From sofa-ark with Apache License 2.0 | 4 votes |
@Override public boolean isInfoEnabled(Marker marker) { return logger.isInfoEnabled(); }
Example #30
Source File: RateLogger.java From more-lambdas-java with Artistic License 2.0 | 4 votes |
@Override public boolean isTraceEnabled(Marker marker) { return logger.isTraceEnabled(marker); }